Search code examples
ruby-on-railsenvironment-variablesport80

Cannot access environment variables on port 80


I'm working on a rails application and in my dev environment I'm forced to use port 80. Running on any other port that would require me to go to localhost:xxxx isn't gonna work.

I run the application with rvmsudo rails s -p 80 after stopping apache.

Everything works fine except that I can't seem to access my environment variables here. Running on regular ports (3000, 4000, etc) works fine and I can access them when I can use those ports, but when I can't and have to use 80 I'm stuck.

Is there something I should be running when I start up the rails server? Or some alternate way of accessing the environment variables that would work everywhere?


Solution

  • sudo and rvmsudo start a subshell that doesn't contain environment variables. rvmsudo only forwards on certain environment variables see more.

    In your scenario, are you saying that this doesn't work:

    rvmsudo rails s -p 80
    

    And that this does work?

    rvmsudo rails s -p 3000
    

    Also, are you trying to access environment variables other than these: $PATH, $GEM_HOME, $GEM_PATH and $BUNDLE_PATH?