Ruby on rails 运行任何脚本的Rails无效字节
似乎无法理解这一点,尝试运行任何脚本时,我收到以下错误:Ruby on rails 运行任何脚本的Rails无效字节,ruby-on-rails,postgresql,utf-8,Ruby On Rails,Postgresql,Utf 8,似乎无法理解这一点,尝试运行任何脚本时,我收到以下错误: UTF-8中的字节序列无效(ArgumentError) 我有一台全新的OSX机器,使用Ruby 1.9.3和Rails 3.2.1,我已经开发了好几天,没有任何问题 我今天离开了几个小时,现在我不能运行任何脚本 我第一次尝试新迁移时出错,认为这是Postgres的问题,重新安装后,确保所有表都用UTF-8编码 我还重新安装了RVM和Rails 我原以为如果与数据库有关,调试会更容易,但我已经创建了新的应用程序,甚至无法启动服务器,收到了
UTF-8中的字节序列无效(ArgumentError)
我有一台全新的OSX机器,使用Ruby 1.9.3和Rails 3.2.1,我已经开发了好几天,没有任何问题
我今天离开了几个小时,现在我不能运行任何脚本
我第一次尝试新迁移时出错,认为这是Postgres的问题,重新安装后,确保所有表都用UTF-8编码
我还重新安装了RVM和Rails
我原以为如果与数据库有关,调试会更容易,但我已经创建了新的应用程序,甚至无法启动服务器,收到了相同的错误
尝试在sqlite3上的新应用程序中运行服务器的完整堆栈
/Users/mgaughan/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:136:in `split': invalid byte sequence in UTF-8 (ArgumentError)
from /Users/mgaughan/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:136:in `setup_environment'
from /Users/mgaughan/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:13:in `setup'
from /Users/mgaughan/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.0.21/lib/bundler.rb:110:in `setup'
from /Users/mgaughan/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.0.21/lib/bundler/setup.rb:7:in `'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
from /Users/mgaughan/Code/something/config/boot.rb:6:in `'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from script/rails:5:in `'
现在我看得越多,显然postgresql出了问题,因为在postgresql上的应用程序中,bundle安装失败
堆栈跟踪:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb
checking for pg_config... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
/Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:1357:in `split': invalid byte sequence in UTF-8 (ArgumentError)
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:1357:in `find_executable0'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:1384:in `block in find_executable'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
from /Users/mgaughan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/mkmf.rb:1383:in `find_executable'
from extconf.rb:27:in `'
Gem files will remain installed in /Users/mgaughan/.rvm/gems/ruby-1.9.3-p0/gems/pg-0.12.2 for inspection.
Results logged to /Users/mgaughan/.rvm/gems/ruby-1.9.3-p0/gems/pg-0.12.2/ext/gem_make.out
An error occured while installing pg (0.12.2), and Bundler cannot continue.
Make sure that `gem install pg -v '0.12.2'` succeeds before bundling.
它提到要检查的mkmf.log文件为空
所以我猜测Postgresql可能是这个问题的根源,但是我很困惑为什么使用sqlite3的新应用程序仍然会抛出这个字节错误
任何帮助都将不胜感激,如果我能提供更多信息,请告诉我
编辑
这个问题似乎已经自行解决了
我对我的机器所做的唯一改变是按照@Frederick Cheung的建议;我从路径中删除了一个sbin文件夹,该文件夹来自已卸载的旧NGINX安装
也许这就是区别,但我觉得不太可能
不管怎样,我运行了一个命令,一切正常,已经运行了好几天。您的初始值设定项或环境配置(application.rb、development.rb等)是否包含无效字符 如果您从网络上抓取了一个javascript文件,该文件的头中有时髦的字符,则通常会发生这种情况。如果将其包含在application.js中,则链轮解析器会对其进行抖动
在本例中,它看起来像是在您尝试运行应用程序时出现的,因此它向我建议,在初始化期间使用的某个文件中,它是无效字符。您的初始化程序或环境配置(application.rb、development.rb等)是否包含无效字符 如果您从网络上抓取了一个javascript文件,该文件的头中有时髦的字符,则通常会发生这种情况。如果将其包含在application.js中,则链轮解析器会对其进行抖动
在本例中,它看起来像是在您尝试运行应用程序时出现的,因此它向我建议它是初始化期间使用的其中一个文件中的无效字符。根据stacktrace判断,
路径
环境变量包含一些不好的数据。首先,我要检查它并删除任何看起来不属于它的内容根据stacktrace判断,PATH
环境变量包含一些不好的数据。我会先检查它,然后移除任何看起来不属于它的东西我不相信是这样,这就是为什么我如此困惑的原因。基本上,我正在开发的一个应用程序在我完成开发后运行良好,但当天晚些时候它给出了这个错误,没有添加任何内容。最大的困惑是,如果我从头开始创建一个应用程序,不碰任何东西,而是尝试运行rails,它会抛出相同的错误。啊,对不起,误解了。我不确定到时候我能帮上多少忙:/我不相信是这样,这就是为什么我如此难堪的原因。基本上,我正在开发的一个应用程序在我完成开发后运行良好,但当天晚些时候它给出了这个错误,没有添加任何内容。最大的困惑是,如果我从头开始创建一个应用程序,不碰任何东西,而是尝试运行rails,它会抛出相同的错误。啊,对不起,误解了。我不确定到时候我能帮上多少忙:/