Volta: Volta fails to set executable for node/yarn on Mac OS

Created on 24 Sep 2019  路  19Comments  路  Source: volta-cli/volta

It seems that install volta when using a fish shell, the executables do not get properly set. Therefore, my system version is either non-existent or it uses a version from a previous workflow.

As a temporary work around, I copied the executables found in ~/.volta/bin/ to /usr/local/bin/. But this breaks down when using volta for multiple projects, with different versions.

bug

All 19 comments

@kingscott thanks for reporting this. Can you provide specific steps to reproduce? I wrote the fish installation setup (because I needed it for myself!) and use it regularly.

Hey @chriskrycho, sure thing!

I installed volta via the instructions found here. And then I'd install a version of node, for example:

$  volta install node

...but it didn't populate the executable node command that I expected in my terminal. I ran it a few different times, and opened new fish sessions, but nothing. :/

As mentioned, I had to manually copy the executable to the /usr/local/bin folder.

_Edit_: I don't think volta install node@stable actually works, but I did [email protected] (which is the latest stable).

Huh! What OS and OS version, and what fish version, are you using?

Fish: 3.0.2
MacOS: 10.14.15

It seems that ~/.volta/load.fish just needs to be added to ~/.fish/functions/volta.fish and then executed in the config.fish file and everything works properly.

Maybe I'm wrong here, but could I tackle this if it's the case? @chriskrycho

馃 I find your description of the situation pretty confusing (not at all meaning you're describing it badly!). What is your PATH defined as? (I'm happy to support your doing the work to fix it, I just want to make sure we actually understand the problem correctly first!).

Here's what I'm experiencing on a fresh install

volta

Yep, that makes sense given your write up. Thanks! Can you share the Volta-specific contents of your fish config and the output of echo $PATH?

For my volta-specific additions to my fish config, it is just the code found in ~/.volta/load.fish:

function volta
    # Use the user's existing `VOLTA_HOME` environment value if set; otherwise,
    # use a default of `~/.volta`.
    if set -q VOLTA_HOME;
        set VOLTA_ROOT "$VOLTA_HOME"
    else
        set VOLTA_ROOT "$HOME/.volta"
    end

    # Generate 32 bits of randomness, to avoid clashing with concurrent executions.
    set -x VOLTA_POSTSCRIPT "$VOLTA_ROOT/tmp/volta_tmp_"(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" ")".fish"

    # Forward the arguments to the Volta executable.
    env VOLTA_SHELL=fish "$VOLTA_ROOT/volta" $argv
    set EXIT_CODE $status

    # Call the post-invocation script if it is present, then delete it.
    # This allows the invocation to potentially modify the caller's environment (e.g., PATH).
    if test -f "$VOLTA_POSTSCRIPT"
        source $VOLTA_POSTSCRIPT
        rm "$VOLTA_POSTSCRIPT"
    end

    set -e VOLTA_POSTSCRIPT
    return $EXIT_CODE
end

And here is my echo $PATH output:

/Users/kingscott/.rvm/gems/ruby-2.3.0/bin /Users/kingscott/.rvm/gems/ruby-2.3.0@global/bin /Users/kingscott/.rvm/rubies/ruby-2.3.0/bin /Users/kingscott/.rvm/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin

So, you're missing the relevant Volta entries on your PATH, as I expected, and this is because your fish.config is missing the bits the installer normally adds. 馃

Can you remove the contents of ~/.volta/load.fish from your fish.config and re-run the installer? The installer normally just sets up your PATH and adds a hook to run load.fish, but if it finds references to Volta already present, it skips that action.

Steps followed:

  • Remove ~/.volta directory
  • Remove volta function from my fish config
  • Remove any other leftovers from volta
  • Ran the documented command to install volta via CLI

My path:

/Users/kingscott/.rvm/gems/ruby-2.3.0/bin /Users/kingscott/.rvm/gems/ruby-2.3.0@global/bin /Users/kingscott/.rvm/rubies/ruby-2.3.0/bin /Users/kingscott/.rvm/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin

And volta is not defined.

Thanks! What if anything does your fish config have now?

It has nothing at the moment.

[And if I want to get things working again, I just copy the contents of ~/.volta/load.fish into my fish.config]

That鈥檚 helpful, thanks! One of us will try to see what changed/broke in the installer!

FWIW, we think the problem is how the installer is identifying which profile to use! @charlespierce has an idea for how to solve it; in the meantime, there are two solutions:

  1. (Simplest option) When installing, run:

    $ curl https://get.volta.sh | env PROFILE=$HOME/.config/fish/config.fish bash
    

    This should set up your profile correctly.

  2. (Manual option) Instead of copying load.fish into your shell directly, copy what we are currently failing to install into your config:

    set -gx VOLTA_HOME "$HOME/.volta"
    test -s "$VOLTA_HOME/load.fish"; and source "$VOLTA_HOME/load.fish"
    

I experienced something similar, when switching to fish from zsh, the installer seems to get confused. On the first go, it did nothing so i wiped out ~/.volta, but after that the installer tried to modify .zshrc. Running env PROFILE=$HOME/.config/fish/config.fish before the installer seemed to do the trick.

@chriskrycho Note volta-install is an internal copy of the install script. In general that should be:

$ curl https://get.volta.sh | env PROFILE=$HOME/.config/fish/config.fish bash

Excellent point; updated!

I believe with the updated installer / volta setup logic, this should no longer be an issue. We now will install into any / all shell configurations that we find, instead of just the first. Feel free to re-open if there are still installation issues on Fish.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dherman picture dherman  路  5Comments

MikeVensel picture MikeVensel  路  4Comments

olivier-martin-sf picture olivier-martin-sf  路  5Comments

mikrostew picture mikrostew  路  3Comments

pjking07 picture pjking07  路  5Comments