Uli
Uli

Reputation: 11

rake assets:precompile fails on windows machine

I have a similar problem as reported many times, e.g. here: rake assets:precompile RAILS_ENV=production not working as required

My setup is as follows:

-- rails 5.1
-- any application (e.g. an empty one, just generated the app, bundle, rake assets:precompile)
-- error: 

c:\RailsApps\asset_pipeline_test>bundle exec rake assets:precompile I, [2018-05-08T01:26:06.195454 #7876] INFO -- : Writing c:/RailsApps/asset_pipeline_test/public/assets/application-a51a53658dfaa975cb4363f51d14bccf24d66c3d90c2186bf834c157151c4bd1.js rake aborted! NoMethodError: undefined method `post' for nil:NilClass Tasks: TOP => assets:precompile

The same error occours for different apps.

The difference to other reported issues:

-- I am using two similar w7pro machines
-- on one machine rake assets:precompile is working
-- on the other machine it's failing

I put a 1:1 copy of the app and the Ruby/Rails installation folder from the working machine to the one failing.

I checked any kind of environmental variables and found no difference.

I guess there is a difference between the machines outside the app and Ruby setup.

Question: what difference could that be? Both machines are originally set up by identical OS images (by my company's IT), but they are not fresh of course

Uli

Upvotes: 1

Views: 344

Answers (1)

Prakash Thiru
Prakash Thiru

Reputation: 41

Check the ruby version of system's current user

rvm list

Make sure the same is taken during bundle. If it takes someother version install ruby for the user properly.

Also do bundle in a better way

bundle exec rake assets:precompile RAILS_ENV=production

bundle's ruby version should match with current system users' ruby version. bundle could be found at

/usr/bin/

or

/usr/local/

Upvotes: 1

Related Questions