reodon59
reodon59

Reputation: 17

RAILS_ENV=production is not recognized as a cmdlet, function, etc

So I'm learning Rails on Windows 8 box from on online source. In the lesson below, I'm trying to change the Rails environment from development to production and precompile some files before uploading them to heroku.

When I run the below command:

PS C:\Users\username\work\stukdo> RAILS_ENV=production bundle exec rake assets:precompile

I get this:

RAILS_ENV=production : The term 'RAILS_ENV=production' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At line:1 char:1
+ RAILS_ENV=production bundle exec rake assets:precompile
+ ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (RAILS_ENV=production:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

I have looked everywhere but cannot get this command to work. I've updated the PATH in my Windows box, but to no avail.

I have Rails ver. 4.1.8 and Ruby 1.9.3 running on the windows box. Any ideas? Sorry if this is a novice question, but I'm stuck.

Upvotes: 1

Views: 2212

Answers (1)

bigtunacan
bigtunacan

Reputation: 4986

RAILS_ENV=production is used from Linux (or variant thereof) terminals to set an environment variable prior to calling some command.

To do this in Windows you will need to set the environment variable the Windows way. This would look something like this.

set RAILS_ENV=production
bundle exec rake assets:precompile

EDIT: Based on comment from TC

Setting Heroku to use production is a different problem altogether.

Details are provided on Heroku's site at the following link.

https://devcenter.heroku.com/articles/multiple-environments

The short version though you need to create a production remote and then push to that remote.

heroku create --remote production
git push production master

Upvotes: 2

Related Questions