【问题标题】:Webpacker compilation failed - ERROR: [Errno 21] Is a directory: 'bin'Webpacker 编译失败 - 错误:[Errno 21] 是目录:'bin'
【发布时间】:2020-03-29 00:46:24
【问题描述】:

我刚开始使用 Docker,一切都在进行,直到我尝试访问我的超级基本应用程序的页面。我得到了这个:

web_1    | [Webpacker] Compiling...
web_1    | [Webpacker] Compilation failed:
web_1    | ERROR: [Errno 21] Is a directory: 'bin'
web_1    | CRITICAL:root:Traceback (most recent call last):
web_1    |   File "/usr/lib/python2.7/dist-packages/cliapp/app.py", line 182, in _run
web_1    |     self.settings.load_configs()
web_1    |   File "/usr/lib/python2.7/dist-packages/cliapp/settings.py", line 829, in load_configs
web_1    |     self._read_ini(pathname, f)
web_1    |   File "/usr/lib/python2.7/dist-packages/cliapp/settings.py", line 838, in _read_ini
web_1    |     cp.readfp(f)
web_1    |   File "/usr/lib/python2.7/ConfigParser.py", line 324, in readfp
web_1    |     self._read(fp, filename)
web_1    |   File "/usr/lib/python2.7/ConfigParser.py", line 512, in _read
web_1    |     raise MissingSectionHeaderError(fpname, lineno, line)
web_1    | MissingSectionHeaderError: File contains no section headers.
web_1    | file: /usr/src/app/config/webpack/development.js, line: 1
web_1    | "process.env.NODE_ENV = process.env.NODE_ENV || 'development'\n"
web_1    | 
web_1    | Traceback (most recent call last):
web_1    |   File "/usr/lib/python2.7/dist-packages/cliapp/app.py", line 182, in _run
web_1    |     self.settings.load_configs()
web_1    |   File "/usr/lib/python2.7/dist-packages/cliapp/settings.py", line 829, in load_configs
web_1    |     self._read_ini(pathname, f)
web_1    |   File "/usr/lib/python2.7/dist-packages/cliapp/settings.py", line 838, in _read_ini
web_1    |     cp.readfp(f)
web_1    |   File "/usr/lib/python2.7/ConfigParser.py", line 324, in readfp
web_1    |     self._read(fp, filename)
web_1    |   File "/usr/lib/python2.7/ConfigParser.py", line 512, in _read
web_1    |     raise MissingSectionHeaderError(fpname, lineno, line)
web_1    | MissingSectionHeaderError: File contains no section headers.
web_1    | file: /usr/src/app/config/webpack/development.js, line: 1
web_1    | "process.env.NODE_ENV = process.env.NODE_ENV || 'development'\n"

这是我第一次看到这个错误。

这是我的 docker-compose.yml

version: '3'                                                                                                                                                                                                                          

services:

  web:
    build: .
    ports:
      - "3000:3000"
    volumes:
      - .:/usr/src/app

这是我的 Dockerfile:

FROM ruby:2.6                                                                                                                                                                                                                         

LABEL maintainer="ejvalmores@gmail.com"

RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \
nodejs

RUN apt-get install -yqq yarn

COPY Gemfile* /usr/src/app/
WORKDIR /usr/src/app
RUN bundle install

COPY . /usr/src/app

CMD ["bin/rails", "s", "-b", "0.0.0.0"]

这是我的 Gemfile:

source 'https://rubygems.org'                                                                                                                                                                                                         
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.6.5'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.2', '>= 6.0.2.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.4'
# Use Puma as the app server
gem 'puma', '~> 4.1'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 4.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Active Storage variant
# gem 'image_processing', '~> 1.2'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 2.15'
  gem 'selenium-webdriver'
  # Easy installation and use of web drivers to run system tests with browsers
  gem 'webdrivers'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem 'redis'

有人遇到过这个错误吗?请帮忙。谢谢!

【问题讨论】:

    标签: ruby-on-rails ruby docker ruby-on-rails-6 webpacker


    【解决方案1】:

    我遇到了同样的错误。也许你需要安装最新版本的nodejs和yarn。

    将此添加到您的 Dockerfile:

    (假设你有 curl,如果没有安装它)

    RUN curl -sL https://deb.nodesource.com/setup_12.x  | bash -
    RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add
    RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
    RUN apt-get update -qq && apt-get install -y nodejs yarn
    

    然后在最后我添加以下内容进行编译:

    RUN npm rebuild node-sass #maybe you don't need it, I do
    RUN bundle exec rails assets:precompile
    

    也是我发现大部分此类信息的来源:https://github.com/yarnpkg/yarn/issues/7329

    【讨论】:

      猜你喜欢
      • 2022-12-07
      • 2021-05-06
      • 1970-01-01
      • 2021-06-13
      • 1970-01-01
      • 1970-01-01
      • 2020-11-20
      • 2023-03-10
      • 1970-01-01
      相关资源
      最近更新 更多