keybase / node-installer

An installer/updater for the node client.
BSD 3-Clause "New" or "Revised" License
117 stars 9 forks source link

Installer does not work without sudo on Ubuntu #39

Closed rohandhruva closed 10 years ago

rohandhruva commented 10 years ago

I chose to install keybase-installer without the -g option (to avoid creating global files). The package was installed by npm in ~/node_modules/, in the "local mode". Running keybase-installer now fails because it tries to install in /usr/bin instead of ~/node_modules/.bin.

Why is keybase not trying to install in local mode?

Here is the output:

rdhruva@ubuntu:~$ keybase-installer 
error: Permission denied installing to /usr/bin: try running `sudo keybase-installer`
rdhruva@ubuntu:~$ keybase-installer -d 
debug: + cmd.run 0.1.6
debug: ++ Installer::run
debug: +++ Installer::test_gpg
debug: --- Installer::test_gpg -> OK
debug: +++ Installer::test_npm
debug: --- Installer::test_npm -> OK
debug: +++ Installer::test_npm_install
debug: ||| Writing temporary file, to see if install will work: /usr/bin/.keybase_test_install_65d1993df79e33579272
debug: --- Installer::test_npm_install
error: Permission denied installing to /usr/bin: try running `sudo keybase-installer`
rdhruva@ubuntu:~$ which keybase-installer 
/home/rdhruva/node_modules/.bin/keybase-installer
maxtaco commented 10 years ago

This is a case I didn't think of. We're trying to balance not installing as root if at all possible, but also not to confuse those who don't have as much experience as you.

There's a workaround for you for now, which is just to use --prefix=.. Do you think this is sufficient?

rohandhruva commented 10 years ago

How do I use --prefix?

rdhruva@ubuntu:~$ keybase-installer --prefix=/home/rdhruva/temp/foo
error: Permission denied installing to /usr/bin: try running `sudo keybase-installer`
rdhruva@ubuntu:~$ keybase-installer -n "npm --prefix=/home/rdhruva/temp/foo" 
execvp(): No such file or directory

error: The npm command you specified `npm --prefix=/home/rdhruva/temp/foo` wasn't found

Sorry I am not too familiar with npm. I installed keybase-installer in my homedir, and added ~/node_modules/.bin to my $PATH manually.

maxtaco commented 10 years ago

It's a bug, let me fix it, give me 5 min. Thanks.

rohandhruva commented 10 years ago

Hm.. I see this was referenced in issue #38 and fixed in 4fc0921: do I not have the latest version? I did npm install keybase-installer a few minutes back.

Also, the environment variable workaround in that issue doesn't seem to work:

rdhruva@ubuntu:~$ NPM_CONFIG_PREFIX=/home/rdhruva/temp/foo keybase-installer 
error: Permission denied installing to /usr/bin: try running `sudo keybase-installer`
maxtaco commented 10 years ago

Closed in c11c02e9e4a1790e63abda11c01c7865d3fe8d5d aka keybase-installer@v0.1.7

Try an npm install keybase-installer and see if that helps. Thanks for your feedback.

rohandhruva commented 10 years ago

Still doesn't work:

rdhruva@ubuntu:~$ keybase-installer --prefix=/home/rdhruva/temp/foo
error: Permission denied installing to /usr/bin: try running `sudo keybase-installer`
rdhruva@ubuntu:~$ keybase-installer --prefix=/home/rdhruva/temp/foo -d 
error: Permission denied installing to /usr/bin: try running `sudo keybase-installer`
rdhruva@ubuntu:~$ keybase-installer -d  --prefix=/home/rdhruva/temp/foo 
debug: + cmd.run 0.1.7
debug: ++ Installer::run
debug: +++ Installer::test_gpg
debug: --- Installer::test_gpg -> OK
debug: +++ Installer::test_npm
debug: --- Installer::test_npm -> OK
debug: +++ Installer::test_npm_install
debug: ||| Writing temporary file, to see if install will work: /usr/bin/.keybase_test_install_58a0b327577f1b617c6c
debug: --- Installer::test_npm_install
error: Permission denied installing to /usr/bin: try running `sudo keybase-installer`

The help message still doesn't show the --prefix option. Additionally, note that in the second command, -d was not parsed, which is a bug in itself.

maxtaco commented 10 years ago

try without the equals:

keybase-installer --prefix /home/rdhruva/temp/foo

rohandhruva commented 10 years ago

Perfect, that worked! Any idea why --prefix doesn't appear in the help, though?

rdhruva@ubuntu:~$ keybase-installer --help 
usage: keybase-installer [-vh?] [-C] [-u <url-prefix>] [<keybase-version>]

        Upgrade or install a version of keybase.  Check signatures for Keybase.io's signing
        key. You can provide a specific version or by default you'll get the most recent
        version.

Boolean Flags:
        -d/--debug         -- Turn on debugging output
        -v/--version       -- Print the version and quit
        -h/--help          -- Print the help message and quit
        -C/--skip-cleanup  -- Don't delete temporary files after install
        -j/--key-json      -- Output the hash of the JSON file corresponding to the built-in keyset
        -S/--no-https      -- Don't use HTTP. This should be safe since we check PGP sigs on everything.

Options:
        -u/--url-prefix    -- Specify a URL prefix for fetching (default: [object Object])
        -g/--gpg           -- Use a GPG command other than `gpg`
        -n/--npm           -- Use an npm command other than `npm`
        -k/--keyring-dir   -- Where to store our GPG keys (default: ~/.keybase-installer/keyring)
        -p/--prefix        -- Install to the given prefix (rather than where `npm` installs by default)

Version: 0.1.7
rohandhruva commented 10 years ago

Also, why is it trying to create directories bin and lib in the --prefix, instead of using the standard node_modules and node_modules/.bin? I assume it is to keep compatibility with being installed in /usr?

maxtaco commented 10 years ago

it's there! see the last one.

-p/--prefix -- Install to the given prefix (rather than where npm installs by default)

rohandhruva commented 10 years ago

it's there! see the last one.

Wow -- that was pretty silly of me, sorry!

maxtaco commented 10 years ago

No worries, as for the install layout, we're doing with whatever node wants to do. Now, it could be you want one more flag, which is --local, whereby keybase-installer installs into the local node_modules dir. We can do that, I'll put it on the list, though it's not urgent since not many others have asked for it.

maxtaco commented 10 years ago

See #43 for the new --local flag. And see #42 for eventually handling --foo=bar style command-line flags.