使用:
ruby "2.4.0"
gem "rails", "5.1.0.rc1"
gem "pg", "0.18.4" # postgresql database
gem foreman
gem "webpacker", git: "https://github.com/rails/webpacker"
我跑的时候,
bundle exec foreman start -f Procfile.dev
其中包含以下3行:
rails: bin/rails s -b 0.0.0.0
webpack-dev-server: bin/webpack-dev-server
memcached: memcached
这是rails s的内容
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands
这是webpack-dev-server的内容:
#!/usr/bin/env ruby
$stdout.sync = true
require "shellwords"
require "yaml"
ENV["RAILS_ENV"] ||= "development"
RAILS_ENV = ENV["RAILS_ENV"]
ENV["NODE_ENV"] ||= RAILS_ENV
NODE_ENV = ENV["NODE_ENV"]
APP_PATH = File.expand_path("../", __dir__)
CONFIG_PATH = File.join(APP_PATH, "config/webpack/paths.yml")
begin
paths = YAML.load(File.read(CONFIG_PATH))[NODE_ENV]
NODE_MODULES_PATH = File.join(APP_PATH.shellescape, paths["node_modules"])
WEBPACK_CONFIG_PATH = File.join(APP_PATH.shellescape, paths["config"])
WEBPACK_BIN = "#{NODE_MODULES_PATH}/.bin/webpack-dev-server"
DEV_SERVER_CONFIG = "#{WEBPACK_CONFIG_PATH}/development.server.js"
rescue Errno::ENOENT, NoMethodError
puts "Configuration not found in config/webpacker/paths.yml."
puts "Please run bundle exec rails webpacker:install to install webpacker"
exit!
end
Dir.chdir(APP_PATH) do
exec "NODE_PATH=#{NODE_MODULES_PATH} #{WEBPACK_BIN} --progress --color " \
"--config #{DEV_SERVER_CONFIG}"
end
我收到此错误:
bundler: failed to load command: foreman (/Users/annie/.rbenv/versions/2.4.0/bin/foreman)
在细节上,我也可以看到这个并且不确定如何修复
bad URI(is not URI?): tcp://localhost:3000:5000 (URI::InvalidURIError)
如果我在不同的终端中分别运行Procfile中的2个命令(bin / rails s -b 0.0.0.0& bin / webpack-dev-server),那么一切正常(没有错误)
造成3000:5000的原因是什么?
我该如何解决?
非常感谢答案 0 :(得分:1)
确保没有在某处设置名为UTF-8
的ENV变量。我使用gem dotenv-rails 时遇到了同样的问题。我的 .env 文件中有一行:
HOST
我摆脱了那条线,工头再次工作。