简体   繁体   English

耙资产:在Windows机器上预编译失败

[英]rake assets:precompile fails on windows machine

I have a similar problem as reported many times, eg here: rake assets:precompile RAILS_ENV=production not working as required 我有多次报告类似的问题,例如,在这里: rake asset:precompile RAILS_ENV = production无法按要求工作

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! c:\\ RailsApps \\ asset_pipeline_test>捆绑执行rake资产:预编译I,[2018-05-08T01:26:06.195454#7876] INFO-:编写c:/ RailsApps / asset_pipeline_test / public / assets / application-a51a53658dfaa975cb4363f51d14bccf24流产了! NoMethodError: undefined method `post' for nil:NilClass Tasks: TOP => assets:precompile NoMethodError:nil:NilClass的未定义方法“ post”任务:TOP => asset: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. 我将应用程序和Ruby / Rails安装文件夹的1:1副本从工作机上放到了失败的地方。

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. 我猜该应用程序之外的机器与Ruby设置之间存在差异。

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 这两台机器最初都是由相同的操作系统映像(由我公司的IT部门)设置的,但是它们并不是新鲜的

Uli 乌里

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. 如果需要其他版本,请为用户正确安装ruby。

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/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM