understing what is Spring and Binstub, instead of $bundle exec [rails_commands]
, it's better to use $./bin/[rails_commands]
(rails_commands : rails, rspec, setup, rake, etc )
And it's even better to use direnv, since it will shorhand us to type $./bin/[rails_commands]
(any executable file in ./bin), to just $[rails_commands]
, for example: instead of $./bin/rails s
, we can just type $rails s
.
$ brew install direnv
- add below line to ~/.bashrc or ~/.zshrc (base on your profile)
eval "$(direnv hook bash)"
- create
.envrc
in the root of your project (example here is based on rails project) - add below line to the file
export PATH=./bin:$PATH
- there's a security notice
.envrc is not allowed
when ever we cd into the project directory, below command will whitelist the current dir.
$ direnv allow .
now when you test, instead of ~/.rbenv/shims/rails, it show ./bin/rails
$ which rails
> ./bin/rails
Enjoy!!