Git Product home page Git Product logo

Comments (13)

mxhold avatar mxhold commented on June 6, 2024 1

A quick fix to this for those that are having this issue is to add the /etc/profile.d/chruby.sh script as the chruby README suggests:

if [ -n "$BASH_VERSION" ] || [ -n "$ZSH_VERSION" ]; then
  source /usr/local/share/chruby/chruby.sh
fi

This works because if you run chruby-exec from a non-interactive shell (which is what Capistrano does by default unless you set :pty, true) then it will run the sub-shell as a non-interactive, login shell. This means ~/.bashrc will not get loaded but /etc/profile.d will.

There is a pull request for fixing this at postmodern/chruby#250 but it looks like it needs to be updated.

from chruby.

hungryzi avatar hungryzi commented on June 6, 2024

I got the same error. Did you find out why @KamilLelonek ?

from chruby.

KamilLelonek avatar KamilLelonek commented on June 6, 2024

I threw away chruby.

from chruby.

grzuy avatar grzuy commented on June 6, 2024

Same issue here. Anyone found the reason?

from chruby.

h0jeZvgoxFepBQ2C avatar h0jeZvgoxFepBQ2C commented on June 6, 2024

Anyone found a solution?

from chruby.

cannikin avatar cannikin commented on June 6, 2024

Also getting this. Logging into the server and running chruby-exec works fine...

from chruby.

fnordfish avatar fnordfish commented on June 6, 2024

I had to set :pty, true (which is not a good idea). Think it's a chruby-exec problem.

from chruby.

leehambley avatar leehambley commented on June 6, 2024

FWIW we documented this behaviour: http://capistranorb.com/documentation/faq/why-does-something-work-in-my-ssh-session-but-not-in-capistrano/#which-shell-startup-files-do-get-loaded?

from chruby.

fnordfish avatar fnordfish commented on June 6, 2024

Thanks for the pointers!

from chruby.

leehambley avatar leehambley commented on June 6, 2024

For sure that graphic is one that starts only to make sense once you actually understand what it tells you, but it won't teach you anything :-D

from chruby.

lfender6445 avatar lfender6445 commented on June 6, 2024

I ran into similar issue, but sudo appears to work fine

› /bin/bash -c '/usr/local/bin/chruby-exec 2.2.3 -- gem -v'
chruby-exec: RUBY and COMMAND required
› /bin/bash -c 'sudo /usr/local/bin/chruby-exec 2.2.3 -- gem -v'
2.4.5.1

from chruby.

baccenfutter avatar baccenfutter commented on June 6, 2024

So, I just ran into this bug and researched it all the way down to the root cause.

The script chruby-exec first does a source /usr/local/share/chruby/chruby.sh then does some logic and finally runs exec $SHELL ... chruby ....

This can not work. exec will not carry shell functions to the new fork. This behaviour was changed after shell-shock. Neither the Ubtunu-14.04 nor the Gentoo ~amd64 I have here will carry the chruby shell function in the newly forked shell after exec. So to make it clear, the exec statement clears all the shell functions that chruby-exec previously sourced to function properly.

I can not explain why some users above describe to only see this when using sudo. Perhaps some quirky work-around of the individual distro they are using? Perhaps not using Bash?

source <some-shell-functions>
exec $SHELL -c 'binary-using-shell-functions-above'

... will never work.

from chruby.

baccenfutter avatar baccenfutter commented on June 6, 2024

Proposed fix: remove the exec.

Why exec in the first place?
Why not just $SHELL -c "chruby ..."?

from chruby.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.