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

Single-user installer botches the .profile file for weird home directories #5535

Open
grahamc opened this issue Nov 11, 2021 · 7 comments
Open
Labels

Comments

@grahamc
Copy link
Member

grahamc commented Nov 11, 2021

Describe the bug

After installing Nix it says to load the nix.sh profile, like this:

Installation finished!  To ensure that the necessary environment
variables are set, either log in again, or type

  . /home/grahamc/.nix-profile/etc/profile.d/nix.sh

in your shell.

however, if you have spaces in your name it breaks. It gets worse from there:

Installation finished!  To ensure that the necessary environment
variables are set, either log in again, or type

  . / /\//*/'/"//.nix-profile/etc/profile.d/nix.sh

in your shell.

Unfortunately this is not the only problem. After installing Nix I get errors when logging in:

-e: command not found
-bash: / /\//*/'/"//.profile: line 29: unexpected EOF while looking for matching `"'
-bash: / /\//*/'/"//.profile: line 30: syntax error: unexpected end of file

this is because these paths are not properly handled in the modifications to my .profile:

$ tail -n1 .profile 
if [ -e / /\//*/'/"//.nix-profile/etc/profile.d/nix.sh ]; then . / /\//*/'/"//.nix-profile/etc/profile.d/nix.sh; fi # added by Nix installer

Steps To Reproduce

  1. Play silly games (make your home directory / /\\/*/'/")
  2. Install Nix
  3. Win silly prizes (a lot of software breaks by mishandling the data)

Expected behavior

Nix should properly handle the $HOME variable contents, or leave expanding it to the caller.

nix-env --version output

2.4

Additional context

n/a

@grahamc grahamc added the bug label Nov 11, 2021
@abathur
Copy link
Member

abathur commented Nov 11, 2021

Good candidate for that installer test suite :)

@abathur
Copy link
Member

abathur commented Nov 11, 2021

edit: nm; this was semi-recently touched in #3834 and #5459, though after looking at both it looks like the problem existed before

@ghost
Copy link

ghost commented Nov 29, 2021

I am observing this in a fresh Debian installation provisioned with lima.
In my case, .profile has an errant -e:

-e 
if [ -e /home/me.linux/.nix-profile/etc/profile.d/nix.sh ]; then . /home/me.linux/.nix-profile/etc/profile.d/nix.sh; fi # added by Nix installer

@abathur
Copy link
Member

abathur commented Nov 29, 2021

@efx I think you're actually seeing the issue documented in #5458 and fixed in #5459 (not yet released)

@ghost
Copy link

ghost commented Nov 30, 2021

@abathur awesome, thanks for clarifying!

@stale
Copy link

stale bot commented Jul 11, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Jul 11, 2022
@parke
Copy link

parke commented Oct 4, 2023

Here is an additional error case: If ~/.profile does not exist, then the install prints the following:

Note: a multi-user installation is possible. See https://nixos.org/manual/nix/stable/installation/installing-binary.html#multi-user-installation
performing a single-user installation of Nix...
copying Nix to /nix/store.................................................
replacing old 'nix-2.18.1'
installing 'nix-2.18.1'
unpacking channels...

Installation finished!  To ensure that the necessary environment
variables are set, please add the line

  . 

to your shell profile (e.g. ~/.profile).

@stale stale bot removed the stale label Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants