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

"erb-formatter not found by bundler" when using gem install #24

Open
archonic opened this issue Apr 1, 2023 · 10 comments
Open

"erb-formatter not found by bundler" when using gem install #24

archonic opened this issue Apr 1, 2023 · 10 comments
Assignees
Labels
question Further information is requested

Comments

@archonic
Copy link

archonic commented Apr 1, 2023

The readme says we should be able to use this extension with gem install erb-formatter. I've done that and which erb-format works, but the extension seems unable to find it unless it's in the Gemfile. I've also tried adding this to my settings.json:

"erb-formatter.commandPath": "/Users/user/.asdf/shims/erb-format"

Is the gem check only looking in the Gemfile?

@ghost
Copy link

ghost commented Jul 1, 2023

I'm getting this error in VSCode:

erb-formatter not found by bundler. Add `gem 'erb-formatter'` to your Gemfile and run `bundle install`.

I have it listed in my Gemfile. I have it installed globally on my machine. I added the commandPath to settings.json like described in the comment above. I don't know why I'm getting this error message. It's annoying.

For now, I'm just disabling the extension to quiet it.

If anybody has a fix for this, please explain.

@elia
Copy link
Member

elia commented Jul 7, 2023

Is the gem check only looking in the Gemfile?

Sorry for the delay 🙏

It's not, the way it checks for presence in the Gemfile is by running bundle show erb-formatter:

See https://github.com/nebulab/erb-formatter-vscode/blob/e82c54421be0670dac0df25c26460e6ed70d5a5f/erb-formatter.js#L61

In your VS Code logs you should be able to see the command that gets actually executed and that should be really helpful in understanding what went wrong:

https://github.com/nebulab/erb-formatter-vscode/blob/e82c54421be0670dac0df25c26460e6ed70d5a5f/erb-formatter.js#L29

@elia elia self-assigned this Jul 7, 2023
@elia elia added the question Further information is requested label Jul 7, 2023
@mrbme
Copy link

mrbme commented Jul 13, 2023

I'm getting the same error too. When I run "bundle show erb-formatter" I get
/Users/myname/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/erb-formatter-0.4.3

@brodyreid
Copy link

Same error :( Is there a fix for this? VS Code output shows this failed command:
Command failed: /Users/user/.gem/ruby/3.2.1/bin/erb-format --stdin-filename "/Users/user/project/app/views/home/index.html.erb" --print-width 80 /Users/user/.gem/ruby/3.2.1/gems/erb-formatter-0.4.3/lib/erb/formatter.rb:159:in 'tag_stack_pop': (RuntimeError)

@brodyreid
Copy link

Same error :( Is there a fix for this? VS Code output shows this failed command: Command failed: /Users/user/.gem/ruby/3.2.1/bin/erb-format --stdin-filename "/Users/user/project/app/views/home/index.html.erb" --print-width 80 /Users/user/.gem/ruby/3.2.1/gems/erb-formatter-0.4.3/lib/erb/formatter.rb:159:in 'tag_stack_pop': (RuntimeError)

Oh I understand now: the formatter was just erroring because of incorrect tags. Is there a way to have VS Code highlight these issues in the editor?

@ScotterC
Copy link

+1 to this issue. great gem when it was working.

@davidwessman
Copy link

I have had to add something like:

"terminal.integrated.profiles.osx": {
    "zsh": {
      "path": "/bin/zsh",
      "args": [
        "-l",
        "-i"
      ]
    }
  },

to my User settings to have same setup as in my normal terminal.
Not sure if the formatter uses terminal.integrated, but maybe there is another profile?

@elia
Copy link
Member

elia commented Sep 27, 2023

Oh I understand now: the formatter was just erroring because of incorrect tags. Is there a way to have VS Code highlight these issues in the editor?

I would very much be in favor of highlighting stuff in the editor, I'll give it a crack but if anyone wants to jump in I'd be very happy to collaborate/merge 🙌

https://github.com/nebulab/erb-formatter-vscode

@elia
Copy link
Member

elia commented Sep 27, 2023

Not sure if the formatter uses terminal.integrated, but maybe there is another profile?

The extension is simply using execSync it generates the updated code and uses the editor api to replace the contents, the idea is to make it work even for unsaved files.

@ScotterC
Copy link

For those encountering this error but not understanding the 'incorrect tags' comment. This error can come up when there's an exception by ERB formatter when trying to format - say a missing </div> in a weird spot. The way to diagnose is VSCode Output and select 'erb formatter' in the dropdown since normal output won't show the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants