Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object doesn't support this property or method Rails Windows 64bit

I installed Rails on my Surface Pro 3 and run into this error after trying to view a page. I have tried several suggestions such as installing rubyracer with libv8 but it didn't help.

TypeError: Object doesn't support this property or method (in c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/turbolinks-2.5.3/lib/assets/javascripts/turbolinks.js.coffee)

Here is my gemfile:

source 'http://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.8'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer',  platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc
gem 'libv8', '~> 3.16.14.7'

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin]
gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
gem 'font-awesome-rails'
gem 'simple_form'
gem 'devise'
like image 702
Matt P Avatar asked Feb 04 '15 02:02

Matt P


5 Answers

Coffee script 1.9.0 doesn't play well with Windows. On my Windows 7 machine, using version 1.8.0 solved this problem.

Add to Gemfile

gem 'coffee-script-source', '1.8.0'

then, run

bundle update coffee-script-source

and restart the server (if needed)

like image 196
Jessa Avatar answered Nov 19 '22 11:11

Jessa


Had the same issue (doing a 'hello world' application of all things...) but couldn't get the coffeescript 1.8.0 fix to work. Found a solution here: http://mech.xyz/how-to-fix-ruby-on-rails-turbolinks-js-coffee-error-windows/

Steps:

  1. Navigate to \app\views\layouts\application.html.erb
  2. Change line 6 from

<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>

to

<%= javascript_include_tag '**defaults**', 'data-turbolinks-track' => true %>

Did this and it's been working fine now.

like image 15
Jaime Avatar answered Nov 19 '22 11:11

Jaime


Contrary to popular belief, Rails is NOT cross platform compatible as they claim. If it was it would work on windows, out of the box. Like you I have tried every available option.

This was solved using Ruby 2.1.5p273/Rails 4.2.0

I changed execjs to use UTF-8 with jscript, no effect. This was done by editing C:\RailsInstaller\Ruby2.1.0\lib\ruby\gems\2.1.0\gems\execjs-2.2.2\lib\execjs\runtimes.rb changing the JScript = block to the following.

JScript = ExternalRuntime.new(
  name:        "JScript",
  command:     "cscript //E:jscript //Nologo",
  runner_path: ExecJS.root + "/support/jscript_runner.js",
  encoding:    'UTF-8' # CScript with //U returns UTF-16LE
)

I also tried installing therubyracer which leads to problems with the libv8 dependency not compiling. I added my python 2.7 install to the windows system path, and installed libv8. Then it said libv8 was installed but when I tried to install therubyracer it said libv8 couldn't be found. I uninstalled libv8 and tried again and it said libv8 couldn't be compiled. That was enough for me to determine that therubyracer was not going to work on windows, so I commented it out of my Gemfile, leaving python 2.7 on my windows system path.

I updated coffee-script-source, by adding the following to my Gemfile

gem 'coffee-script-source', '1.9.0'

After adding coffee-script-source to my Gemfile I ran gem update coffee-script-source , this also didn't solve the problem.

I then installed node.js, this worked for 5 minutes until I generated a new controller, and it was broken again.

Note: After installing node.js you need to open a new command prompt to get the updates to your system path that are setup when node.js installs.

Finally what fixed this problem was to open up the app\assets\javascripts\application.js file and remove the last line which says

//= require_tree .

Lastly run the following command to make sure coffee-script is properly installed in Node.js

npm install -g coffee-script
like image 8
Ralph Ritoch Avatar answered Nov 19 '22 12:11

Ralph Ritoch


This is caused by an incompatibility between 64bit Windows and the CoffeeScript gem.

This is indeed a CoffeeScript issue. It only appears to affect 64 bit Windows machines. 32bit Windows is fine.

CoffeeScript occurs in two places by default in Rails:

  • The default scaffold generator makes a coffee script file.
  • Turbolinks is CoffeeScript.

The simplest way to fix this is to simply remove the CoffeeScript. You probably don't need it anyway.

  1. Delete the generated coffeeScript file in app/assets/javascripts.
  2. Remove the turbolinks gem from the gemfile, then bundle install.
  3. Edit assets/stylesheets/application.js to delete the turbolinks include.
like image 7
superluminary Avatar answered Nov 19 '22 11:11

superluminary


I found your error look like this ExecJS::RuntimeError on Windows trying to follow rubytutorial

I fix on my system by un-comment the line // = require_tree in 'assets\javascripts\application.js'

= require_tree
like image 4
suhao399 Avatar answered Nov 19 '22 11:11

suhao399