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
rdbg --util=gen-sockpath generate socket names that are too long #982
Comments
Now we use the following logic to get tmpdir. def self.unix_domain_socket_tmpdir
require 'tmpdir'
if tmpdir = Dir.tmpdir
path = File.join(tmpdir, "ruby-debug-sock-#{Process.uid}")
unless File.exist?(path)
d = Dir.mktmpdir
File.rename(d, path)
end
check_dir_authority(path)
end
end and File name is specified with: def self.create_unix_domain_socket_name_prefix(base_dir = unix_domain_socket_dir)
user = ENV['USER'] || 'UnknownUser'
File.join(base_dir, "ruby-debug-#{user}")
end and long user name will generates long name. Do you have an idea to short them? |
We could probably shorten |
I just came across this too. My username is 23 characters long but I just did a test and macOS seems to allow usernames up to 80† characters long. I assume other *nix OSes are similar? Perhaps including the full username in socket path is not advisable?
If it's desirable to keep username, can we just keep the first 20 characters? def self.create_unix_domain_socket_name_prefix(base_dir = unix_domain_socket_dir)
user = ENV['USER'] || 'UnknownUser'
- File.join(base_dir, "ruby-debug-#{user}")
+ File.join(base_dir, "ruby-debug-#{user.slice[0-19]}")
end Edit: †I tried to create a user with a 100 letter name but it only let me enter the first 80. Verified with
|
Ok, now I changed the UNIX domain socket file name to use UID instead of username
and I hope it will solve the problem. |
without
|
Your environment
ruby -v
: ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [arm64-darwin22]rdbg -v
: rdbg 1.8.0 {:mode=>:start, :no_color=>nil}Describe the bug
rdbg --util=gen-sockpath
generate a socket name that is too long. Running that command on my machine does:As I understand, this is called when running
RUBY_DEBUG_OPEN=true rails s
to establish a socket path for where the remote debugger will connect. This is the output from starting the rails server, which crashes immediately because the socket path is too long.To Reproduce
bundle exec rdbg --util=gen-sockpath
. I haven't dug in to find why there is so much randomness added to the socket path, I'm not sure if this is always like that or related to some configuration on my machine. I also happen to have a long login name, pushing the already long socket name over the limit.Expected behavior
Socket name generated is under 104 bytes, working for all lengths of user name.
Additional context
I'm aware that I can set the socket path manually to get a shorter one, eg
RUBY_DEBUG_OPEN=true RUBY_DEBUG_SOCK_PATH=tmp/rdbg.sock rails s
. I would prefer if it was working out of the box without the need of extra config, because then I have to also setup the matching path in VSCode. Currently VSCode doesn't seem to accept a relative path.The text was updated successfully, but these errors were encountered: