Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev setup instructions missing RAILS_ENV=development and bundle exec #1016

Open
SamStephens opened this issue Nov 14, 2022 · 3 comments
Open

Comments

@SamStephens
Copy link

For https://github.com/mastodon/documentation/blob/31a159d456a245efe1514b29a6694aa9fb115eb4/content/en/dev/setup.md, both the rails db:setup and foreman start commands needed me to set the RAILS_ENV environment variable to development. The foreman command in particular was confusing, because whilst the rails db:setup command clearly told me the RAILS_ENV environment variable was unset, I think foreman defaulted to production, as it complained I hadn't compiled assets.

In additional, as Rails is managed via bundler, should we not be using bundle exec?

So I think these command lines should be

RAILS_ENV=development bundle exec rails db:setup

and

RAILS_ENV=development foreman start
@SamStephens
Copy link
Author

I know there's a big documentation update pending as #991, but I've checked that pull request and it does not change these instructions.

@trwnh
Copy link
Member

trwnh commented Nov 14, 2022

i have not personally tried a from-source dev environment setup yet, but my feedback based on what i know currently is:

  • RAILS_ENV might need to be set, yeah, i'm not sure but that seems sensible
  • prefixing rails db:setup with bundle exec i'm not so sure about -- i'll have to look into that

@SamStephens
Copy link
Author

SamStephens commented Nov 14, 2022

@trwnh I might be wrong on bundle exec honestly. Doing a little more research and looking at https://guides.rubyonrails.org/getting_started.html, it looks like bin/rails might be the appropriate thing. Unfortunately the rails guides don't appear particularly useful for this, as they have you directly running gem install rails rather than using a Gemfile.

My understanding is that if you use the binstub from bin/rails (in your local repository), Rails takes care of running the right Rails version. If you use bundle exec rails, Bundler makes sure you use the right Rails from your Gemfile. But if you just run bare rails and have multiple versions of Rails installed, you're not guaranteed that the rails executable that is in your path is the matching one for your current environment.

It's worth that Procfile.dev does use bundle exec for the puma and sidekiq commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants