postmodern / chruby

Changes the current Ruby
MIT License
2.85k stars 190 forks source link

Invoking chruby in bash scripts yields no change #404

Closed codemang closed 5 years ago

codemang commented 5 years ago

Apologies in advance if creating an Issue is not the proper way to go about asking this, but don't know of a better forum for general questions.

I'm building a bootstrapping script for new computers and want to use chruby to install a specific version of ruby. I have chruby installed properly and have confirmed I can change the ruby version from the command line. However, if I have a bash script that does this.

#!/bin/bash
 source /usr/local/share/chruby/chruby.sh && chruby ruby-2.5.0

The ruby version remains unchanged. Furthermore, there are no error messages or non-zero exit codes. Is there something obvious I'm missing?

codemang commented 5 years ago

Looks like I misunderstood how chruby works. I now realize that calling chruby ruby-2.5.0 only sets ruby for the local shell. I've added a .ruby-version file to my home directory and all is well. Closing.