Open mintuhouse opened 1 year ago
I am having the same issue, although from line 89:
[WARN] undefined method `present?' for "MyClassName":String
Did you mean? prepend
/Users/ryan/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/solargraph-rails-1.1.0/lib/solargraph/rails/schema.rb:89:in `infer_table_names'
/Users/ryan/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/solargraph-rails-1.1.0/lib/solargraph/rails/schema.rb:84:in `find_table'
/Users/ryan/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/solargraph-rails-1.1.0/lib/solargraph/rails/schema.rb:41:in `process'
/Users/ryan/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/solargraph-rails-1.1.0/lib/solargraph-rails.rb:45:in `block in local'
/Users/ryan/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/solargraph-rails-1.1.0/lib/solargraph-rails.rb:60:in `run_feature'
/Users/ryan/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/solargraph-rails-1.1.0/lib/solargraph-rails.rb:45:in `local'
/Users/ryan/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/solargraph-0.49.0/lib/solargraph/convention.rb:29:in `block in for_local'
I am getting the same issue as well.
@iftheshoefritz any updates on this?
I got this error after upgraded to Rails 7.1.2 from 7.0.6 (or maybe other dependencies in my Gemfile)
Which caused schema.rb
not working properly.
Any workaround yet?
For others facing this issue, i have resolved it in my codebase by generating a binstub for solargraph and configuring vscode to use bin/solargraph
as its path
In this binstub I load active_support explicitly before calling original executable for solargraph
#!/usr/bin/env ruby
# frozen_string_literal: true
#
# This file was generated by Bundler.
#
# The application 'solargraph' is installed as part of a gem, and
# this file is here to facilitate running it.
#
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
bundle_binstub = File.expand_path("bundle", __dir__)
if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end
require "rubygems"
require "bundler/setup"
# Detect problems if any using `solargraph scan`
require "active_support/all" # Fix for https://github.com/iftheshoefritz/solargraph-rails/issues/60
require "solargraph/rails/schema" # Fix for https://github.com/iftheshoefritz/solargraph-rails/issues/61
Solargraph::Rails::Schema::RUBY_TYPES[:enum] = "String"
load Gem.bin_path("solargraph", "solargraph")
I also created a temporary patch for this issue as a gem library, solargraph-rails-patch-for-rails71. With this gem library, we don't face this error even if we use Rails 7.1.
Please install this gem and update .solargraph.yml as follows:
plugins:
- solargraph-rails
- solargraph-rails-patch-for-rails71 # Add this line
Seem this is still an issue
I also created a temporary patch for this issue as a gem library, solargraph-rails-patch-for-rails71. With this gem library, we don't face this error even if we use Rails 7.1.
Please install this gem and update .solargraph.yml as follows:
plugins: - solargraph-rails - solargraph-rails-patch-for-rails71 # Add this line
@masamitsu-murase Life saver!!!! This fixed it for me! Thank you so much!
For future readers using Vim: I'm using solargraph-rails with the coc.nvim LSP in Vim. I'm using the coc-solargraph LSP, along with these gems, on OSX, with Rails 7.1.3, ruby 3.2.2 This is my CocConfig
{
"solargraph.commandPath": "/Users/<username>/.rbenv/shims/solargraph",
"solargraph.useBundler": false
}
Getting below error and dont see schema.rb columns in suggestions when I start solargraph with bundle
Could it be because active_support is not loaded?