Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I get a file not found error from rubocop (using linter-rubocop) #57

Closed
jaresty opened this issue May 25, 2014 · 32 comments
Closed

I get a file not found error from rubocop (using linter-rubocop) #57

jaresty opened this issue May 25, 2014 · 32 comments

Comments

@jaresty
Copy link

jaresty commented May 25, 2014

When editing a file, I see no linting, but if I open the javascript console I can see an error message that says "env: ruby_executable_hooks: No such file or directory".

  • I have rubocop installed using rvm
  • The command that appears to be run looks like /Users/jaresty/.rvm/gems/ruby-2.1.2/bin/rubocop --format emacs /var/folders/2_/7s_9bc4s5q586np5tmjh3tn80000gr/T/114421-34324-5q1bi0source.ruby
@iam4x iam4x added the bug label May 25, 2014
@park9140 park9140 added this to the 0.4.9 milestone May 25, 2014
@iam4x
Copy link
Contributor

iam4x commented May 26, 2014

Hi @jaresty I'll look into it,
Can you provide a gist of an example file to lint?

And the output of:

  • $ rubocop --version
  • $ ruby --version

I have ruby 2.0.0p451 installed with rvm and gem rubocop v0.22.0 and no issues.

@iam4x iam4x self-assigned this May 26, 2014
@iam4x iam4x modified the milestones: 0.4.8, 0.4.9 May 26, 2014
@jaresty
Copy link
Author

jaresty commented May 26, 2014

It happens with any ruby file at all. I'm not sure if it's a
linter-rubocop issue or a linter issue.

Thanks,
Josh

2014年5月26日月曜日、Maxime [email protected]さんは書きました:

Hi @jaresty https://github.com/jaresty I'll look into it,
Can you provide a gist of an example file to lint?

Thank's


Reply to this email directly or view it on GitHubhttps://github.com//issues/57#issuecomment-44177051
.

Best,
Josh Aresty
Web Developer
The MathWorks

@iam4x
Copy link
Contributor

iam4x commented May 26, 2014

@jaresty I edited my message, as you answered by mail you didn't noticed it.

It seems more an issue with your installation of rubocop can you give me your ruby --version and rubocop --version.

Also can you try to lint a file with the command line directly in shell with: $ rubocop path/to/file.rb and give me the result.

@jaresty
Copy link
Author

jaresty commented May 26, 2014

% rubocop --version
0.21.0

% ruby --version
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]

/Users/jaresty/.rvm/gems/ruby-2.1.2/bin/rubocop --format emacs /var/folders/2_/7s_9bc4s5q586np5tmjh3tn80000gr/T/114421-34216-1eagftfsource.ruby
No such file or directory @ rb_sysopen - /var/folders/2_/7s_9bc4s5q586np5tmjh3tn80000gr/T/114421-34216-1eagftfsource.ruby
/Users/jaresty/.rvm/gems/ruby-2.1.2/gems/rubocop-0.21.0/lib/rubocop/source_parser.rb:10:in `read'
/Users/jaresty/.rvm/gems/ruby-2.1.2/gems/rubocop-0.21.0/lib/rubocop/source_parser.rb:10:in `parse_file'
/Users/jaresty/.rvm/gems/ruby-2.1.2/gems/rubocop-0.21.0/lib/rubocop/file_inspector.rb:86:in `process_source'
/Users/jaresty/.rvm/gems/ruby-2.1.2/gems/rubocop-0.21.0/lib/rubocop/file_inspector.rb:52:in `process_file'
/Users/jaresty/.rvm/gems/ruby-2.1.2/gems/rubocop-0.21.0/lib/rubocop/file_inspector.rb:23:in `block in process_files'
/Users/jaresty/.rvm/gems/ruby-2.1.2/gems/rubocop-0.21.0/lib/rubocop/file_inspector.rb:21:in `each'
/Users/jaresty/.rvm/gems/ruby-2.1.2/gems/rubocop-0.21.0/lib/rubocop/file_inspector.rb:21:in `process_files'
/Users/jaresty/.rvm/gems/ruby-2.1.2/gems/rubocop-0.21.0/lib/rubocop/cli.rb:31:in `run'
/Users/jaresty/.rvm/gems/ruby-2.1.2/gems/rubocop-0.21.0/bin/rubocop:14:in `block in <top (required)>'
/Users/jaresty/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/benchmark.rb:294:in `realtime'
/Users/jaresty/.rvm/gems/ruby-2.1.2/gems/rubocop-0.21.0/bin/rubocop:13:in `<top (required)>'
/Users/jaresty/.rvm/gems/ruby-2.1.2/bin/rubocop:23:in `load'
/Users/jaresty/.rvm/gems/ruby-2.1.2/bin/rubocop:23:in `<main>'
/Users/jaresty/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
/Users/jaresty/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'

% /Users/jaresty/.rvm/gems/ruby-2.1.2/bin/rubocop --format emacs ~/Desktop/roley-poley/player.rb
/Users/jaresty/Desktop/roley-poley/player.rb:1:80: C: Line is too long. [85/79]
/Users/jaresty/Desktop/roley-poley/player.rb:3:80: C: Line is too long. [123/79]
/Users/jaresty/Desktop/roley-poley/player.rb:5:1: C: Missing top-level class documentation comment.
/Users/jaresty/Desktop/roley-poley/player.rb:12:3: C: Use `attr_reader` to define trivial reader methods.
/Users/jaresty/Desktop/roley-poley/player.rb:17:1: C: Missing top-level module documentation comment.
/Users/jaresty/Desktop/roley-poley/player.rb:23:1: C: Missing top-level class documentation comment.
/Users/jaresty/Desktop/roley-poley/player.rb:33:5: C: Use self-assignment shorthand `+=`.
/Users/jaresty/Desktop/roley-poley/player.rb:37:1: C: Missing top-level class documentation comment.
/Users/jaresty/Desktop/roley-poley/player.rb:38:3: C: Missing top-level class documentation comment.
/Users/jaresty/Desktop/roley-poley/player.rb:40:31: W: Ambiguous negative number operator. Parenthesize the method arguments if it's surely a negative number operator, or add a whitespace to the right of the `-` if it should be a subtraction.
/Users/jaresty/Desktop/roley-poley/player.rb:44:3: C: Missing top-level class documentation comment.
/Users/jaresty/Desktop/roley-poley/player.rb:62:4: C: Prefer `$PROGRAM_NAME` over `$0`.
/Users/jaresty/Desktop/roley-poley/player.rb:67:80: C: Line is too long. [102/79]
/Users/jaresty/Desktop/roley-poley/player.rb:72:80: C: Line is too long. [101/79]

I'm seeing some new errors in the console:

editorView.editor.getGrammar().scopeNametext.plain.null-grammar init.coffee:44
linter: run commands linter-view.coffee:109
linter: lintOnModified linter-view.coffee:104
linter: run commands linter-view.coffee:109
Failed to load resource: the server responded with a status of 404 (Not Found) https://api.travis-ci.org/MatthewMueller/cheerio.svg?branch=master
Failed to load resource: the server responded with a status of 404 (Not Found) https://api.travis-ci.org/MatthewMueller/cheerio.png?branch=master
linter: grammar changed init.coffee:34
linter: run commands linter-view.coffee:109
linter: run linter command linter.coffee:77
/Users/jaresty/.rvm/gems/ruby-2.1.2/bin/rubocop --format emacs /var/folders/2_/7s_9bc4s5q586np5tmjh3tn80000gr/T/114426-47784-10jbyahsource.ruby linter.coffee:78
/Users/jaresty/Desktop/roley-poley linter.coffee:79
env: ruby_executable_hooks: No such file or directory

@iam4x
Copy link
Contributor

iam4x commented May 26, 2014

First try to update rubocop version 0.22.0 is out now.

I'm looking into it.

@jaresty
Copy link
Author

jaresty commented May 26, 2014

Did you install ruby with rvm? I will update rubocop as soon as I get back
home (I'm out for the day now)

2014年5月26日月曜日、Maxime [email protected]さんは書きました:

First try to update rubocop it's on version 0.22.0

I'm looking into it.


Reply to this email directly or view it on GitHubhttps://github.com//issues/57#issuecomment-44192135
.

Best,
Josh Aresty
Web Developer
The MathWorks

@iam4x
Copy link
Contributor

iam4x commented May 26, 2014

Yes, installed with rvm too ;)

btw co-workers are telling me that https://github.com/sstephenson/rbenv is better now than RVM (fyi)

Can I have an example file with his extension which fails? Into a gist.

@iam4x
Copy link
Contributor

iam4x commented May 26, 2014

It's looking for /var/folders/2_/7s_9bc4s5q586np5tmjh3tn80000gr/T/114421-34216-1eagftfsource.ruby which doesn't seems to exists. And the extension of the file is kinda weird.

@jaresty
Copy link
Author

jaresty commented May 26, 2014

Right: I don't know where that file name is coming from; I assumed it was
something internal to atom or the linter plugin.

2014年5月26日月曜日、Maxime [email protected]さんは書きました:

It's looking for
/var/folders/2_/7s_9bc4s5q586np5tmjh3tn80000gr/T/114421-34216-1eagftfsource.rubywhich doesn't seems to exists. And the extension of the file is kinda weird.


Reply to this email directly or view it on GitHubhttps://github.com//issues/57#issuecomment-44192773
.

Best,
Josh Aresty
Web Developer
The MathWorks

@iam4x
Copy link
Contributor

iam4x commented May 26, 2014

@jaresty Yep, it's intern to Linter plugin. To lint on modify, we copy the text buffer into a temporary file which will be used by the specific linter.

Normally it should add the correct extension to the file, so something is going wrong. When you have time, give me a not working example file ;)

@jaresty
Copy link
Author

jaresty commented May 26, 2014

Could you send me an example file that works for you too?

2014年5月26日月曜日、Maxime [email protected]さんは書きました:

@jaresty https://github.com/jaresty Yep, it's intern to Linter plugin.
To lint on modify, we copy the text buffer into a temporary file which will
be used by the specific linter.

Normally it should add the correct extension to the file, so something is
going wrong. When you have time, give me a not working exemple file ;)


Reply to this email directly or view it on GitHubhttps://github.com//issues/57#issuecomment-44193288
.

Best,
Josh Aresty
Web Developer
The MathWorks

@iam4x iam4x modified the milestones: 0.4.9, 0.4.8 May 26, 2014
@jaresty
Copy link
Author

jaresty commented May 27, 2014

This file is named player.rb, and produces the error when loaded into the linter. It happens actually with any .rb file I try to use.

# Different take on delegation--always have an identified original message recipient.
#
# Inspired by: http://www.saturnflyer.com/blog/jim/2012/07/06/the-gang-of-four-is-wrong-and-you-dont-understand-delegation/

class Role
  def initialize(delegate)
    @delegate = delegate
  end

  private

  def delegate
    @delegate
  end
end

module ActsAs
  def as(role_class)
    role_class.new self
  end
end

class Account
  include ActsAs

  attr_reader :balance

  def initialize(balance)
    @balance = balance
  end

  def update_balance(amount)
    @balance = @balance + amount
  end
end

class TransferMoney
  class Source < Role
    def withdraw(amount)
      delegate.update_balance -amount
    end
  end

  class Destination < Role
    def deposit(amount)
      delegate.update_balance amount
    end
  end

  def initialize(amount, source, destination)
    @amount      = amount
    @source      = source.as Source
    @destination = destination.as Destination
  end

  def run
    @source.withdraw @amount
    @destination.deposit @amount
  end
end

if $0 == __FILE__

  savings  = Account.new 300
  checking = Account.new 100

  puts "Before transfer, savings contains $#{savings.balance}, checking contains $#{checking.balance}"

  transfer = TransferMoney.new 100, savings, checking
  transfer.run

  puts "After transfer, savings contains $#{savings.balance}, checking contains $#{checking.balance}"

end

@iam4x
Copy link
Contributor

iam4x commented May 30, 2014

Hi @jaresty I add so much work this week, gonna look more into it today. But I have problem to reproduce :/

With your file, on OSX 10.9.3, ruby 2.0.0p451, rubocop 0.22.0 I have no errors:

screen shot 2014-05-30 at 10 36 00 am

@jaresty
Copy link
Author

jaresty commented May 30, 2014

Would it help if I could show you? I can screen share with google plus I
think.

2014年5月30日金曜日、Maxime [email protected]さんは書きました:

Hi @jaresty https://github.com/jaresty I add so much work this week,
gonna look more into it today. But I have problem to reproduce :/


Reply to this email directly or view it on GitHub
#57 (comment).

Best,
Josh Aresty
Web Developer
The MathWorks

@iam4x
Copy link
Contributor

iam4x commented May 30, 2014

@jaresty Okey It seems to doesn't find the temporary file created from the buffer, on what OSX version are you working? They may be an issue while creating the temp file.

@jaresty
Copy link
Author

jaresty commented May 30, 2014

I'm on Mavericks (10.9), but this happened on my work machine running 10.8
too.

Best,
Josh Aresty
Web Developer
The MathWorks

On Fri, May 30, 2014 at 10:31 AM, Maxime Tyler [email protected]
wrote:

@jaresty https://github.com/jaresty Okey It seems to doesn't find the
temporary file created from the buffer, on what OSX version are you
working? They may be an issue while creating the temp file.


Reply to this email directly or view it on GitHub
#57 (comment).

@iam4x
Copy link
Contributor

iam4x commented May 30, 2014

Are other linters working? Like the jshint or coffeelint ?

@jaresty
Copy link
Author

jaresty commented May 30, 2014

jshint doesn't seem to throw errors, but I don't see any visible linting
feedback so I'm not sure if it's really working.

Best,
Josh Aresty
Web Developer
The MathWorks

On Fri, May 30, 2014 at 10:35 AM, Maxime Tyler [email protected]
wrote:

Are other linters working? Like the jshint or coffeelint ?


Reply to this email directly or view it on GitHub
#57 (comment).

@iam4x
Copy link
Contributor

iam4x commented May 30, 2014

@jaresty Looks like you are the only one who can debug this! Can you check if the https://www.npmjs.org/package/temp package works on your system? Sounds like it doesn't create the file from the editor buffer.

I can help you with this if you don't have any experience into node and javascript.

@jaresty
Copy link
Author

jaresty commented May 30, 2014

What command should I run to test the package?

2014年5月30日金曜日、Maxime [email protected]さんは書きました:

@jaresty https://github.com/jaresty Looks like you are the only one who
can debug this! Can you check if the https://www.npmjs.org/package/temp
package works on your system? Sounds like it doesn't create the file from
the editor buffer.

I can help you with this if you don't have any experience into node and
javascript.


Reply to this email directly or view it on GitHub
#57 (comment).

Best,
Josh Aresty
Web Developer
The MathWorks

@iam4x
Copy link
Contributor

iam4x commented Jun 2, 2014

@jaresty You should try to create a little nodejs script using the module. Creating a temporary file and see if it's working on your system. I'm not sure how to help you.

If someone has an idea? @park9140 @hd-deman

@iam4x iam4x modified the milestones: 0.4.10, 0.4.9 Jun 2, 2014
@jaresty
Copy link
Author

jaresty commented Jun 2, 2014

Is there some sample code I could look to to get a specific example? Where
in the package is the tempfile code used? It would help if I could make my
example as close to the package's usage as possible.

Thanks,

Josh

Best,
Josh Aresty
Web Developer
The MathWorks

On Mon, Jun 2, 2014 at 9:34 AM, Maxime Tyler [email protected]
wrote:

@jaresty https://github.com/jaresty You should try to create a little
nodejs script using the module. Creating a temporary file and see if it's
working on your system. I'm not sure how to help you.

If someone has an idea? @park9140 https://github.com/park9140 @hd-deman
https://github.com/hd-deman


Reply to this email directly or view it on GitHub
#57 (comment).

@jaresty
Copy link
Author

jaresty commented Jun 2, 2014

I used the example I found on the module website, copied and pasted into
the console in atom, and didn't get any errors:

// Fake data
var myData = "foo\nbar\nfoo\nbaz";

// Process the data (note: error handling omitted)
temp.open('myprefix', function(err, info) {
if (!err) {
fs.write(info.fd, myData);
fs.close(info.fd, function(err) {
exec("grep foo '" + info.path + "' | wc -l", function(err, stdout) {
console.log(stdout.trim());
});
});
}
});

undefined
2

Best,
Josh Aresty
Web Developer
The MathWorks

On Mon, Jun 2, 2014 at 11:15 AM, Josh Aresty [email protected] wrote:

Is there some sample code I could look to to get a specific example?
Where in the package is the tempfile code used? It would help if I could
make my example as close to the package's usage as possible.

Thanks,

Josh

Best,
Josh Aresty
Web Developer
The MathWorks

On Mon, Jun 2, 2014 at 9:34 AM, Maxime Tyler [email protected]
wrote:

@jaresty https://github.com/jaresty You should try to create a little
nodejs script using the module. Creating a temporary file and see if it's
working on your system. I'm not sure how to help you.

If someone has an idea? @park9140 https://github.com/park9140 @hd-deman
https://github.com/hd-deman


Reply to this email directly or view it on GitHub
#57 (comment).

@iam4x
Copy link
Contributor

iam4x commented Jun 2, 2014

Write this in something.js

var temp = require('temp');
temp.track();

// Fake data
var myData = "foo\nbar\nfoo\nbaz";

// Process the data (note: error handling omitted)
temp.open('myprefix', function(err, info) {
  if (!err) {
    fs.write(info.fd, myData);
    fs.close(info.fd, function(err) {
      exec("grep foo '" + info.path + "' | wc -l", function(err, stdout) {
        console.log(stdout.trim());
      });
    });
  }
});

And then run in your shell: $ node something.js

You need to install the module temp by running: $ npm install -g temp

@jaresty
Copy link
Author

jaresty commented Jun 3, 2014

When I run this code, the result is "2". It works on my system.

Best,
Josh Aresty
Web Developer
The MathWorks

On Mon, Jun 2, 2014 at 11:45 AM, Maxime Tyler [email protected]
wrote:

Write this in something.js

var temp = require('temp');
temp.track();

// Fake data
var myData = "foo\nbar\nfoo\nbaz";

// Process the data (note: error handling omitted)
temp.open('myprefix', function(err, info) {
if (!err) {
fs.write(info.fd, myData);
fs.close(info.fd, function(err) {
exec("grep foo '" + info.path + "' | wc -l", function(err, stdout) {
console.log(stdout.trim());
});
});
}
});

And then run in your shell: $ node something.js

You need to install the module temp by running: $ npm install -g temp


Reply to this email directly or view it on GitHub
#57 (comment).

@jaresty
Copy link
Author

jaresty commented Jun 3, 2014

I think I've figured out the issue:

On a mac when you install rubocop using rvm and try to set up the linter-rubocop package to point to the rvm (not the mac-system) rubocop, that file contains the line #! env ruby_executable_hooks, which gives a file-not-found error on the mac since your windowed session does not know how to access rvm.

@iam4x
Copy link
Contributor

iam4x commented Jun 3, 2014

Mind blown

Waaaahou!

@park9140
Copy link

park9140 commented Jun 3, 2014

@jaresty, try installing atom command line aliases and then start atom from the command line. This issue exists in a bunch of the linters in sublime as well and that fixes the issue there.

The underlying problem being that certain package managers like nodenv, rbenv, rvm... only install their path in the bash profile, and in osx this file does not get added to the standard application context.

I would suggest that we do an interactive process for discovering a linter location. Each linter could provide guesses for the linter install location, and failing that the base linter could alert the user to input the base linter location so that they are told when the above issue results in not finding the linter executable requirement.

@johanneswuerbach
Copy link

Can't the bash_profile not be loaded into the atom / linter environment? This would solve this issue more automatically and terminal commands would also work in linters.

@park9140
Copy link

park9140 commented Jun 3, 2014

It could, however there are still those among us who do not use bash profile as well. I use fish, and a couple other people around my office use zsh, neither of which use the bash_profile for sourcing path information by default. So even if we pulled the bash profile we would not guarantee access to the correct path data. Though I would love to see atom automatically include the bash profile path info.

@jaresty
Copy link
Author

jaresty commented Jun 3, 2014

@park9140 that did it. Good idea-thanks!

@dmnd
Copy link

dmnd commented Sep 9, 2014

The specific issue here seems to be resolved. Closing, but see #150 for @johanneswuerbach's suggesting of loading the profile into Atom.

@dmnd dmnd closed this as completed Sep 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants