Max Power Max Power - 7 months ago 49
Linux Question

"You don't have [ ] in your PATH," but is in [echo $PATH] (Linux)

I am trying to install the github-pages ruby gem on Linux Mint for use with jekyll.

After running

sudo gem install github-pages
I get:

WARNING: You don't have /home/max/.gem/ruby/2.3.0/bin in your PATH,

gem executables will not run. Building native extensions. This could
take a while...
ERROR: Error installing github-pages: ERROR: Failed
to build gem native extension.

The curious thing is that my path, as printed by
echo $PATH
and by
sudo echo $PATH
both include


So how do I end up with that warning that it is not in my PATH?



sudo PATH=$PATH command

It is possible that sudo is scrubbing your path environment variable.

Also if you want to check the path that command with sudo sees run this instead, otherwise $PATH gets extrapolated by current shell.

sudo bash -c 'echo $PATH'