DEV Community


Posted on


rails with spring on direnv

I like Spring

It makes up your development speed by preloading the code.

I highly recommend you to use Spring.

Then, I've installed "Direnv".

It's environment variables management tool by each directory.
When you change the directory, it changes environment variables immediately.

It means, you need not to type 'bin' anymore πŸ˜€

# before
bin/rspec spec/xxx_spec.rb

# after
rspec spec/xxx_spec.rb

How to install and use it?

0. Suppose

I suppose we use 'Mac OSX'

1. install

brew install direnv

2. setup

Open your ~/.bash_profile and write it.

# Direnv
eval "$(direnv hook bash)"

Make .envrc file at root directory of your app.

touch .envrc
echo 'PATH_add bin' > .envrc

Then, you'll see following message.

direnv: error /Users/your_name/your_app/.envrc is blocked. Run `direnv allow` to approve its content

So, Run it.

direnv allow

3. try using it

rspec spec/xxx_spec.rb

Finish πŸŽ‰

Not only this

It seems more nice useful ways to use.
i.e, docker with direnv.

Top comments (2)

gaultierq profile image
Quentin Gaultier

nice post

codesalley profile image
Code Salley

there's no instruction as how to deploy a docker container with direnv.

All DEV content is created by the community!

Hey, if you're landing here for the first time, you should know that this website is a global community of folks who blog about their experiences to help folks like you out.

Sign up now if you're curious. It's free!