tcp://localhost:3000:5000 (URI::InvalidURIError) 当 运行 在 Procfile 中
tcp://localhost:3000:5000 (URI::InvalidURIError) when running in Procfile
使用:
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
这里是railss
的内容
#!/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?
我该如何解决?
非常感谢
确保没有在某处设置名为 HOST
的 ENV 变量。我在使用 gem dotenv-rails 时遇到了同样的问题。我的 .env 文件中有一行:
HOST=localhost:3000
我摆脱了那条线,工头又开始工作了。
使用:
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
这里是railss
的内容#!/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?
我该如何解决?
非常感谢
确保没有在某处设置名为 HOST
的 ENV 变量。我在使用 gem dotenv-rails 时遇到了同样的问题。我的 .env 文件中有一行:
HOST=localhost:3000
我摆脱了那条线,工头又开始工作了。