【问题标题】:Fly deployment fails: RUN bundle exec rails assets:precompileFly 部署失败:RUN bundle exec rails assets:precompile
【发布时间】:2022-12-11 05:32:09
【问题描述】:

我最近升级到 Rails 7。一切都在本地工作(包括 bundle exec rails assets:precompile 但是,如果我在 Docker 中构建我的应用程序(部署到 Fly),我会看到这一行:RUN bundle exec rails assets:precompile 然后事情失败并显示此消息:

#23 16.19 Compiling...
#23 18.46 Compilation failed:
#23 18.46 Internal Error: project@workspace:.: This package doesn't seem to be present in your lockfile; run "yarn install" to update the lockfile
#23 18.46     at pQ.getCandidates (/root/.volta/tools/image/yarn/3.3.0/bin/yarn.js:435:5146)
#23 18.46     at Wf.getCandidates (/root/.volta/tools/image/yarn/3.3.0/bin/yarn.js:391:1264)
#23 18.46     at /root/.volta/tools/image/yarn/3.3.0/bin/yarn.js:439:7695
#23 18.46     at Rf (/root/.volta/tools/image/yarn/3.3.0/bin/yarn.js:390:8965)
#23 18.46     at ge (/root/.volta/tools/image/yarn/3.3.0/bin/yarn.js:439:7675)
#23 18.46
------
Error failed to fetch an image or build from source: error building: executor failed running [/bin/bash -c bundle exec rails assets:precompile]: exit code: 1

据我所知,这个错误#23 18.46 Internal Error: project@workspace:.: This package doesn't seem to be present in your lockfile; run "yarn install" to update the lockfile 是问题的关键(project@workspace 只是我项目的名称@workspace)。通常我希望这会列出一个包,但没有列出。我已经删除了锁定文件,yarn install 有效。 package.json 似乎没有什么不合适的。

关于可能破坏预编译的任何想法?

【问题讨论】:

    标签: ruby-on-rails yarnpkg ruby-on-rails-7 fly


    【解决方案1】:

    看起来 yarn.lock 文件没有正确生成或包含在您的项目中可能存在问题。 yarn 使用此文件来跟踪项目中安装的依赖项的确切版本。如果 yarn.lock 文件不存在或已过期,它可能会导致您在运行 bundle exec rails assets:precompile 时看到的问题。

    解决此问题的一种方法是尝试删除 yarn.lock 文件(如果存在),然后运行 ​​yarn install 生成一个新文件。这应该确保安装了所有依赖项,并且它们的版本正确记录在 yarn.lock 文件中。

    完成后,再次尝试running bundle exec rails assets:precompile,看看问题是否仍然存在。如果是这样,您可能需要更深入地研究错误消息,看看是否有任何其他特定问题导致预编译失败。

    【讨论】:

      猜你喜欢
      • 2018-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多