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

Using paths for options causes error #90

Open
csmithATsquiz opened this issue Mar 25, 2022 · 1 comment
Open

Using paths for options causes error #90

csmithATsquiz opened this issue Mar 25, 2022 · 1 comment

Comments

@csmithATsquiz
Copy link

If I try to use paths for any of the options I'm supposed to be able to, I get the following error:

% ./bin/bundix -i --lockfile=./Gemfile.lock
won't override existing shell.nix but here is what it'd look like:
Traceback (most recent call last):
	10: from ./bin/bundix:5:in `<main>'
	 9: from ./bundix/lib/bundix/commandline.rb:22:in `run'
	 8: from ./bundix/lib/bundix/commandline.rb:35:in `run'
	 7: from ./bundix/lib/bundix/commandline.rb:127:in `handle_init'
	 6: from ./bundix/lib/bundix/commandline.rb:120:in `shell_nix_string'
	 5: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/erb.rb:901:in `result'
	 4: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/erb.rb:901:in `eval'
	 3: from (erb):7:in `bind'
	 2: from ./bundix/lib/bundix/shell_nix_context.rb:20:in `lockfile_path'
	 1: from ./bundix/lib/bundix/shell_nix_context.rb:12:in `path_for'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/pathname.rb:522:in `relative_path_from': different prefix: "/" and "." (ArgumentError)


% ./bin/bundix -i --gemfile=./Gemfile
won't override existing shell.nix but here is what it'd look like:
Traceback (most recent call last):
	10: from ./bin/bundix:5:in `<main>'
	 9: from ./bundix/lib/bundix/commandline.rb:22:in `run'
	 8: from ./bundix/lib/bundix/commandline.rb:35:in `run'
	 7: from ./bundix/lib/bundix/commandline.rb:127:in `handle_init'
	 6: from ./bundix/lib/bundix/commandline.rb:120:in `shell_nix_string'
	 5: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/erb.rb:901:in `result'
	 4: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/erb.rb:901:in `eval'
	 3: from (erb):6:in `bind'
	 2: from ./bundix/lib/bundix/shell_nix_context.rb:16:in `gemfile_path'
	 1: from ./bundix/lib/bundix/shell_nix_context.rb:12:in `path_for'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/pathname.rb:522:in `relative_path_from': different prefix: "/" and "." (ArgumentError)

% ./bin/bundix -i --gemset=blah.nix
won't override existing shell.nix but here is what it'd look like:
Traceback (most recent call last):
	10: from ./bin/bundix:5:in `<main>'
	 9: from ./bundix/lib/bundix/commandline.rb:22:in `run'
	 8: from ./bundix/lib/bundix/commandline.rb:35:in `run'
	 7: from ./bundix/lib/bundix/commandline.rb:127:in `handle_init'
	 6: from ./bundix/lib/bundix/commandline.rb:120:in `shell_nix_string'
	 5: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/erb.rb:901:in `result'
	 4: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/erb.rb:901:in `eval'
	 3: from (erb):8:in `bind'
	 2: from ./bundix/lib/bundix/shell_nix_context.rb:24:in `gemset_path'
	 1: from ./bundix/lib/bundix/shell_nix_context.rb:12:in `path_for'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/pathname.rb:522:in `relative_path_from': different prefix: "/" and "." (ArgumentError)

I can emulate it if I change the command line test:

% git diff test/commandline.rb
diff --git a/test/commandline.rb b/test/commandline.rb
index 1c411e9..5f9a582 100644
--- a/test/commandline.rb
+++ b/test/commandline.rb
@@ -7,9 +7,9 @@ class CommandLineTest < Minitest::Test
     @cli.options = {
       project: "test-project",
       ruby: "test-ruby",
-      gemfile: "test-gemfile",
-      lockfile: "test-lockfile",
-      gemset: "test-gemset",
+      gemfile: Dir.pwd + File::PATH_SEPARATOR + "test-gemfile",
+      lockfile: Dir.pwd + File::PATH_SEPARATOR + "test-lockfile",
+      gemset: Dir.pwd + File::PATH_SEPARATOR + "test-gemset",
     }
   end


% rake
Run options: --seed 11948

# Running:

....E.....

Finished in 0.181851s, 54.9901 runs/s, 153.9722 assertions/s.

  1) Error:
CommandLineTest#test_shell_nix:
ArgumentError: different prefix: "/" and "."
    /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/pathname.rb:522:in `relative_path_from'
    ./bundix/lib/bundix/shell_nix_context.rb:12:in `path_for'
    ./bundix/lib/bundix/shell_nix_context.rb:16:in `gemfile_path'
    (erb):6:in `bind'
    /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/erb.rb:901:in `eval'
    /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/erb.rb:901:in `result'
    ./bundix/lib/bundix/commandline.rb:120:in `shell_nix_string'
    ./bundix/test/commandline.rb:17:in `test_shell_nix'

10 runs, 28 assertions, 0 failures, 1 errors, 0 skips
rake aborted!
Command failed with status (1)
/Library/Ruby/Gems/2.6.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
Tasks: TOP => default => test
(See full trace by running task with --trace)

I'm happy to write up a patch, I'm not sure how you want it though.

Should lib/bundix/commandline.rb turn the full paths (File.expand_path(value)) back in to relative paths ?

@573
Copy link

573 commented Sep 25, 2023

+1

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

No branches or pull requests

2 participants