Giter Club home page Giter Club logo

Comments (6)

aidewoode avatar aidewoode commented on May 26, 2024

Seems like there is a problem with the environment variable configuration of the dev env.
What's you get when you print RAILS_ENV environment variable in shell? echo $RAILS_ENV.

from black_candy.

jaredmoody avatar jaredmoody commented on May 26, 2024

It's production. I'm not very familiar with nix, but I don't see this configured in the shell.nix file - is it coming from the tarball that shell.nix is referencing?

from black_candy.

aidewoode avatar aidewoode commented on May 26, 2024

This shell.nix file doesn't set RAILS_ENV. Do you set a global RAILS_ENV on your environment? When you out the nix shell, what value are you get form RAILS_ENV. Can you try to run nix-shell --pure to see value of RAILS_ENV environment?

from black_candy.

jaredmoody avatar jaredmoody commented on May 26, 2024

Do you set a global RAILS_ENV on your environment?

No, I don't, echo $RAILS_ENV is blank when I'm not in nix, which is why I thought it was being set by nix somewhere.

nix-shell --pure still has RAILS_ENV as production:

❯ echo $RAILS_ENV

❯ nix-shell --pure

[nix-shell:~/code/black_candy]$ echo $RAILS_ENV
production

from black_candy.

aidewoode avatar aidewoode commented on May 26, 2024

🤔 I have tried to configure the dev environment on a plain nix docker container. The value of RAILS_ENV is correct. It's empty. So I think the RAILS_ENV issue maybe is caused by your local environment, and nix has nothing to do with it.

As previously mentioned, you can set rails env on command to avoid the RAILS_ENV issue RAILS_ENV=development rails db:setup. But still got error from database. That's because the database wasn't running yet. It's a bit tricky. Because nix-shell can not auto run service, So when you first time to setup database, you should manually run postgres in nix-shell first, like this postgres. Then launch a new terminal instance to run 'RAILS_ENV=development rails db:setup'. When the database setup is complete, now you can stop the running postgres. Because I have already config the postgres and redis service on Procfile.dev, so you don't have to manually run those services . And use ./bin/dev to run those services.

So the thing is when you first time setup database use nix, you should manually run postgres before it.

I should update the nix dev setup Instructions for this.

from black_candy.

jaredmoody avatar jaredmoody commented on May 26, 2024

I figured out that I had Postgres running already, which prevented Postgres from starting inside the nix shell. I wasn't clear that the nix environment is not completely separate from the host environment.

from black_candy.

Related Issues (20)

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.