Comments (11)
Hi!
Am I reading that right that it's trying to visit a file with a newline at the end? Or is that just a side-effect of copying?
from robe.
Does that file contain any methods? If not:
Check the contents of $LOADED_FEATURES
in the REPL. Does the file name there look right?
If you like, you can try print-debugging the full_scan
method, it should be triggered in this scenario: https://github.com/dgutov/robe/blob/master/lib/robe/sash/const_locations.rb#L56-L69
Or you can try producing a minimal reproduction: a sample project which has this problem. And I'll take it from there.
from robe.
i made a video with the issue https://youtu.be/R_q7MIx93iM, i've checked $LOADED_FEATURES
from robe.
Hi again!
Sorry for the late reply.
You examine the value of $LOADED_FEATURES
near the beginning of the video, and it doesn't have the files in question. But Rails has an autoloading feature: when you access a constant (and module names are constants), the autoloader (most recently, Zeitwerk) can look up existing files in the specified list of directories. So at the end of the scenario the value of this constant should be longer.
But now that I read it again, I see that full_scan
checks that the feature ends with .rb
anyway, so it's unlikely that the problem came from that method.
Here's my next guess: one of the methods on Api::V1::Firm::Members::IndexSerializer
(and ShowSerializer
as well, apparently) returns such broken value in its source_location
method.
Try this snippet in the created inf-ruby Rails console with Robe loaded:
obj = Api::V1::Firm::Members::IndexSerializer
methods = obj.methods(false).map { |m| obj.method(m) } +
(obj.__instance_methods__(false) +
obj.private_instance_methods(false)).map { |m| obj.instance_method(m) }
methods.each { |m| puts "#{m}: #{m.source_location&.first}" }
from robe.
I just ran into this issue as well. Most files would properly open using robe-jump
but certain files would not.
Considering the fact that similar files (i.e. other models) do appear to open, I figured that perhaps the problem was with the contents of the file. It turns out that this is the case.
The following file will not open with robe-jump
.
class User::CreateInput
end
Error (similar to @99monkey):
'/Users/michael/dev/poc/app/inputs/user/create_input.rb
' does not exist
But the same file containing a single method definition will open as expected:
class User::CreateInput
def this_method_definition_fixes_the_problem
end
end
The same applies to the model file.
class Team < ApplicationRecord
has_many :memberships
validates :name, presence: true
# etc
end
Here we have a bunch of class method calls, but no method definitions.
When attempting to open this file using robe-jump
the following error occurs:
'/Users/michael/.gem/rubv/3.1.2/gems/rubocop-1.35.1/lib/rubocop/cop/team.rb
/Users/michael/.gem/ruby/3.1.2/gems/faker-2.23.0/lib/faker/default/team.rb
/Users/michael/dev/poc/app/models/team.rb
'does not exist
I want to open app/models/team.rb but it finds three different paths and doesn't open anything.
However, after adding a method definition it appears to work correctly.
class Team < ApplicationRecord
has_many :memberships
validates :name, presence: true
# etc
def this_method_definition_fixes_the_problem
end
end
Defining a class method instead of an instance method also fixes the problem (def self. this_method_definition_fixes_the_problem
).
Thoughts?
from robe.
Yes, it's my case too, I guess. Serializer in most cases dont have definition of methods. I should check this out..
from robe.
If this happens only when the class has no methods of its own, then...
Could you try changing this line in your local installation
robe/lib/robe/sash/const_locations.rb
Line 63 in 993ae13
to if false
(and maybe commenting out the previous line as well), as see if that fixes the behavior?
from robe.
Aaand never mind, this should fix that. Apparently BSD Grep assigns different meaning to -Z
.
Let me know if the problem remains, of course.
from robe.
Yep, that fixed the issue. Thanks!
Is there a way to limit robe-jump
results to the current project?
robe-jump
on Team
yields the following, and then you can just select the desired file:
.gem/ruby/3.1.2/gems/rubocop-1.35.1/lib/rubocop/cop/team.rb
.gem/ruby/3.1.2/gems/faker-3.0.0/lib/faker/default/team.rb
dev/poc/app/models/team.rb
Not a big deal, but would be nice if it could just assume app/models/team.rb
rather than the other results.
Thanks for the great package.
from robe.
Are you sure to want to limit it to the current project?
One of the benefits of this package is that it can navigate to gems (Solargraph has more difficulties with that). And it's handy to be able to see an implementation of some library feature from time to time.
What we could try to do though, is to sort the locations during completion so that those inside the project come first.
from robe.
There's also the issue that in the other two suggestions the fully-qualified name is longer than Team
, so preprocessing those based on the file contents could work as well.
Anyway, please open a separate issue and we'll continue there.
from robe.
Related Issues (20)
- Robe cannot autostart: "No matching directory found" HOT 4
- Robe not working on Ruby 2.7.1 HOT 3
- robe make emacs freeze on 27 on large projects HOT 16
- Non-string path in LOAD_PATH HOT 3
- Emacs freezes when robe is called while byebug is active on console HOT 3
- How to disable robe? HOT 2
- Get search failed message when run robe-jump. HOT 19
- `Can't find the location` when try to search a class defined on current project. (but can in irb) HOT 6
- `find-tag-marker-ring` breaks `robe-jump` on Emacs 28. HOT 2
- Environment variables HOT 1
- Can't jump to the nested module's class in `enh-ruby-mode`, but ruby-mode works HOT 29
- [Help Request] Not robe issue, just need some professional help on crystal-mode. HOT 10
- CPU spikes during rails process buffer completion HOT 7
- Allow for configurable specificity of `robe-jump` entries HOT 9
- Should be possible to change Robe errors buffer from inf-ruby buffer to another buffer HOT 2
- `robe-completing-read` for `Module: ` is excessively interrupting HOT 20
- `*robe-doc*`: optionally show the method source directly HOT 3
- Consider RBS (when available) for local type inference
- robe hangs Emacs HOT 16
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from robe.