Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bash sources /etc/bashrc #16907

Closed
reckbo opened this issue Jul 13, 2016 · 10 comments
Closed

Bash sources /etc/bashrc #16907

reckbo opened this issue Jul 13, 2016 · 10 comments
Labels
0.kind: question Requests for a specific question to be answered 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md

Comments

@reckbo
Copy link

reckbo commented Jul 13, 2016

Issue description

Why is bash built with

NIX_CFLAGS_COMPILE = ''
-DSYS_BASHRC="/etc/bashrc"
...

by default? The reason I ask is that 1) it reduces purity, and 2) I have nix installed in a cluster environment with no root access, and their /etc/bashrc pollutes my environment -- for example it sets LD_LIBRARY_PATH, which in turn breaks packages such as sed and coreutils (see
errors below).

Reproducible Steps

# below will source '/etc/bashrc' by default
bash
nix-shell

Workarounds are:

bash --norc
nix-shell --run 'bash --norc'

Errors caused by invasive /etc/bashrc

bash: shopt: progcomp: invalid shell option name
sed: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by sed)
bash: sed: command not found
bash: uname: No such file or directory
bash: grep: No such file or directory
bash: sed: No such file or directory
bash: sed: No such file or directory
bash: sed: No such file or directory
bash: sed: No such file or directory
bash: complete: No such file or directory
bash: perl: No such file or directory
bash: uname: No such file or directory
bash: rm: command not found
/data/pnl/soft/nix/store/mjdmg9yslbc5r9176vkpv0vd6k94y7vx-coreutils-8.25/bin/coreutils: /lib64/libc.so.6: version `GLIBC_2.15' not found (required by /data/pnl/soft/nix/store/mjdmg9yslbc5r9176vkpv0vd6k94y7vx-coreutils-8.25/bin/coreutils)
/data/pnl/soft/nix/store/mjdmg9yslbc5r9176vkpv0vd6k94y7vx-coreutils-8.25/bin/coreutils: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /data/pnl/soft/nix/store/mjdmg9yslbc5r9176vkpv0vd6k94y7vx-coreutils-8.25/bin/coreutils)
@FRidh FRidh added 0.kind: question Requests for a specific question to be answered 9.needs: reporter feedback This issue needs the person who filed it to respond labels Jul 16, 2016
@deepfire
Copy link
Contributor

@FRidh -- what feedback is needed?

@FRidh FRidh removed the 9.needs: reporter feedback This issue needs the person who filed it to respond label Aug 26, 2016
@deepfire
Copy link
Contributor

Related:
-- NixOS/nix#976
-- NixOS/nix#903

@edolstra
Copy link
Member

IIRC, this is to ensure that the environment is properly initialised in all cases on NixOS (including e.g. when logging in via ssh host <command>). It might not be necessary (anymore), but this would have to be checked carefully to prevent introducing any regressions.

@mmahut
Copy link
Member

mmahut commented Aug 9, 2019

Are there any updates to this issue, please?

@stale
Copy link

stale bot commented Jun 2, 2020

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 2, 2020
@buffet
Copy link
Member

buffet commented Dec 27, 2022

To add to this: When launching bash from inside nix develop, I get bash: shopt: progcomp: invalid shell option name, and a lot of stuff breaks (e.g. all readline related functionality).

@samueldr
Copy link
Member

Nixpkgs software still follows their system-wide configuration semantics.

Using Nixpkgs' bash outside of NixOS leads to unexpected side-effect, but those side-effects are not exclusive to bash. Singling-out bash here seems like it would cause more issue than it may solve.

nix-shell is not intended to be an isolation layer from the system.

I believe this issue can be closed under this understanding.

Usage of bash in tooling is not affected by this, the rc files being read only in interactive scenarios.

The issues this may cause should be handled where it happens.


If this is wrong, feel free to comment and detail why this should be re-opened. (Or re-open yourselves with explanation if you have the ability to do so.)

@samueldr samueldr closed this as not planned Won't fix, can't repro, duplicate, stale Apr 20, 2024
@buffet
Copy link
Member

buffet commented Apr 22, 2024

The issues this may cause should be handled where it happens.

@samueldr Should I open an issue for NixOS' /etc/bashrc then, or are you saying "this is bash's issue"?

@samueldr
Copy link
Member

samueldr commented Apr 22, 2024

@buffet: yes, an issue dedicated to this problem, with the details about how you have determined this is caused by the /etc/bashrc being read.

It sounds like there is a problem indeed with what you were observing, but the solution is unlikely to be "prevent bash from reading /etc/bashrc" outright, but more likely related to its less-than-hermetic invocation elsewhere.

It could also be some other more nuanced issue with your system configuration, so precise steps in reproduction would be really helpful.

(Do ping me, and cross-reference this issue.)

@buffet
Copy link
Member

buffet commented Apr 23, 2024

Time to figure out what I was doing 1.5 years ago...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: question Requests for a specific question to be answered 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md
Projects
None yet
Development

No branches or pull requests

7 participants