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

Follow install.root #23

Closed
jan-hudec opened this issue Feb 15, 2017 · 18 comments
Closed

Follow install.root #23

jan-hudec opened this issue Feb 15, 2017 · 18 comments

Comments

@jan-hudec
Copy link

cargo install-update -l -a simply finds no packages for me. I suspect it fails to read the ~/.cargo/config where the installation directory is redirected to where it is supposed to be:

[install]
root = "/home/me/.local"
@nabijaczleweli
Copy link
Owner

Well, that's a thing we should probably handle.

Is the redirection thing documented somewhere?

@jan-hudec
Copy link
Author

It is documented in cargo install --help:

The installation root is determined, in order of precedence, by --root, $CARGO_INSTALL_ROOT, the install.root configuration key, and finally the home directory (which is either $CARGO_HOME if set or $HOME/.cargo by default).

I can't find it in the online docs on crates.io now, but it does work as described above.

@nabijaczleweli
Copy link
Owner

cool

@nabijaczleweli nabijaczleweli changed the title Does not find any packages, up-to-date or otherwise Follow instal.root Feb 18, 2017
@nabijaczleweli nabijaczleweli changed the title Follow instal.root Follow install.root Feb 18, 2017
@nabijaczleweli
Copy link
Owner

nabijaczleweli commented Feb 18, 2017

Shit, so I got to this with a 2-day delay, terribly sorry, but it's up, so if you'd like to verify, then I'll make a release.

I'm also retarded and can't use web UIs, sorry about the notification mess.

@nabijaczleweli
Copy link
Owner

Released in v0.7.0

@jan-hudec
Copy link
Author

Does not work.

$ CARGO_INSTALL_ROOT=$HOME/.local cargo install-update -a
    Updating registry `https://github.com/rust-lang/crates.io-index`

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 2, message: "No such file or directory" } }', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libcore/result.rs:837
stack backtrace:
   1:     0x55febaafaf5a - std::sys::imp::backtrace::tracing::imp::write::h3188f035833a2635
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:42
   2:     0x55febaaff7af - std::panicking::default_hook::{{closure}}::h6385b6959a2dd25b
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:349
   3:     0x55febaaff3ae - std::panicking::default_hook::he4f3b61755d7fa95
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:365
   4:     0x55febaaffbf7 - std::panicking::rust_panic_with_hook::hf00b8130f73095ec
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:553
   5:     0x55febaaffa34 - std::panicking::begin_panic::h6227f62cb2cdaeb4
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:515
   6:     0x55febaaff9a9 - std::panicking::begin_panic_fmt::h173eadd80ae64bec
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:499
   7:     0x55febaaff937 - rust_begin_unwind
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:475
   8:     0x55febab277ad - core::panicking::panic_fmt::h3b2d1e30090844ff
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libcore/panicking.rs:69
   9:     0x55febaa20a0b - core::result::unwrap_failed::h822856a25f2ebc35
  10:     0x55febaa2973f - cargo_update::ops::get_index_path::h96d985e54d57771b
  11:     0x55febaa1d8c2 - cargo_install_update::main::hb070feb8c7bac096
  12:     0x55febab06a8a - __rust_maybe_catch_panic
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libpanic_unwind/lib.rs:98
  13:     0x55febab00336 - std::rt::lang_start::h65647f6e36cffdae
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:434
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panic.rs:351
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/rt.rs:57
  14:     0x7f5aa66fa2b0 - __libc_start_main
  15:     0x55febaa1af89 - _start
  16:                0x0 - <unknown>

Note that with $CARGO_INSTALL_ROOT set, the .crates.toml do live in $CARGO_INSTALL_ROOT/.crates.toml, but the registry still lives in $CARGO_HOME, which is different path (still ~/.cargo in my case).

@nabijaczleweli
Copy link
Owner

nabijaczleweli commented Feb 20, 2017

Okay, what about install.root, then?

@jan-hudec
Copy link
Author

With just install.root it just didn't work, no segfault. And they should be equivalent.

@nabijaczleweli
Copy link
Owner

Define "didn't work"? I might be fucking up my testcases here, maybe?

@jan-hudec
Copy link
Author

Like before, cargo install-update -a -l simply prints no crates, though there are some installed. I don't currently have anything out-of-date unfortunately, because I updated it with the old script.

@nabijaczleweli
Copy link
Owner

Can you post the output with this patch:

diff --git a/src/ops.rs b/src/ops.rs
index 9b425d62..3e331e6d 100644
--- a/src/ops.rs
+++ b/src/ops.rs
@@ -181,9 +181,11 @@ impl MainRepoPackage {
 /// # let _ = crates_file;
 /// ```
 pub fn resolve_cargo_directory(cargo_dir: PathBuf, crates_file: PathBuf) -> (PathBuf, PathBuf) {
+    println!("resolving ({}, {})", cargo_dir.display(), crates_file.display());
     if crates_file.exists() {
         let mut crates = String::new();
         File::open(&crates_file).unwrap().read_to_string(&mut crates).unwrap();
+        println!("  {} exists", crates_file.display());

         if let Some(idir) = toml::Parser::new(&crates)
             .parse()
@@ -192,9 +194,11 @@ pub fn resolve_cargo_directory(cargo_dir: PathBuf, crates_file: PathBuf) -> (Pat
             .and_then(|t| t.as_table())
             .and_then(|t| t.get("root"))
             .and_then(|t| t.as_str()) {
+            println!("    {} points at {}", crates_file.display(), idir);
             return resolve_cargo_directory(PathBuf::from(idir), Path::new(idir).join(".crates.toml"));
         }
     }
+    println!("finishing with ({}, {})", cargo_dir.display(), crates_file.display());
     (cargo_dir, crates_file)
 }

Also, contents of (all) your .crates.toml files with locations would be great.

@jan-hudec
Copy link
Author

$ cargo install-update -a -l                                 
resolving (/home/bulb/.cargo, /home/bulb/.cargo/.crates.toml)
finishing with (/home/bulb/.cargo, /home/bulb/.cargo/.crates.toml)
    Updating registry `https://github.com/rust-lang/crates.io-index`

Package  Installed  Latest  Needs update

And as I said in #24, with that revision and the environment, it works:

$ CARGO_INSTALL_ROOT=$HOME/.local/ cargo install-update -a -l
resolving (/home/bulb/.cargo, /home/bulb/.local/.crates.toml)
  /home/bulb/.local/.crates.toml exists
finishing with (/home/bulb/.cargo, /home/bulb/.local/.crates.toml)
    Updating registry `https://github.com/rust-lang/crates.io-index`

Package        Installed      Latest   Needs update
cargo-release  v0.7.0-beta.3  v0.7.0   Yes
git-series     v0.9.1         v0.9.1   No
cargo-license  v0.1.2         v0.1.2   No
cargo-tree     v0.10.1        v0.10.1  No
cargo-modules  v0.3.2         v0.3.2   No
cargo-show     v0.2.2         v0.2.2   No
bindgen        v0.22.0        v0.22.0  No
ripgrep        v0.4.0         v0.4.0   No
cargo-readme   v1.1.0         v1.1.0   No
$ cat ~/.local/.crates.toml 
[v1]
"bindgen 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = ["bindgen"]
"cargo-apk 0.1.7 (path+file:///home/bulb/src/rust/android-rs-glue/cargo-apk)" = ["cargo-apk"]
"cargo-license 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = ["cargo-license"]
"cargo-modules 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = ["cargo-modules"]
"cargo-readme 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = ["cargo-readme"]
"cargo-release 0.7.0-beta.3 (registry+https://github.com/rust-lang/crates.io-index)" = ["cargo-release"]
"cargo-show 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = ["cargo-show"]
"cargo-tree 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = ["cargo-tree"]
"cargo-update 0.7.0 (path+file:///home/bulb/src/rust/cargo-update)" = ["cargo-install-update"]
"git-series 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = ["git-series"]
"libracerd 0.3.3 (path+file:///home/bulb/src/rust/racerd)" = ["racerd"]
"ripgrep 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = ["rg"]

@nabijaczleweli
Copy link
Owner

Ah, it's in config not .crates.toml, dammit

@nabijaczleweli
Copy link
Owner

This patch uses config instead of the crates file for install.root (yes I'm fucking blind) so it should work:

diff --git a/src/ops.rs b/src/ops.rs
index 9b425d62..d885f729 100644
--- a/src/ops.rs
+++ b/src/ops.rs
@@ -166,7 +166,7 @@ impl MainRepoPackage {
 }


-/// [Follow `install.root`](https://github.com/nabijaczleweli/cargo-update/issues/23) in the `.crates.toml` file in the
+/// [Follow `install.root`](https://github.com/nabijaczleweli/cargo-update/issues/23) in the `config` file in the
 /// specified directory up to the final one.
 ///
 /// # Examples
@@ -181,9 +181,10 @@ impl MainRepoPackage {
 /// # let _ = crates_file;
 /// ```
 pub fn resolve_cargo_directory(cargo_dir: PathBuf, crates_file: PathBuf) -> (PathBuf, PathBuf) {
-    if crates_file.exists() {
+    let config_file = crates_file.with_file_name("config");
+    if config_file.exists() {
         let mut crates = String::new();
-        File::open(&crates_file).unwrap().read_to_string(&mut crates).unwrap();
+        File::open(&config_file).unwrap().read_to_string(&mut crates).unwrap();

         if let Some(idir) = toml::Parser::new(&crates)
             .parse()

@jan-hudec
Copy link
Author

If I applied it correctly (copying diffs from comments does not really work; it would be better to push it on a branch), it panics:

$ cargo install-update -a -l                                 
resolving (/home/bulb/.cargo, /home/bulb/.cargo/.crates.toml)
  /home/bulb/.cargo/.crates.toml exists
    /home/bulb/.cargo/.crates.toml points at /home/bulb/.local
resolving (/home/bulb/.local, /home/bulb/.local/.crates.toml)
finishing with (/home/bulb/.local, /home/bulb/.local/.crates.toml)
    Updating registry `https://github.com/rust-lang/crates.io-index`

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 2, message: "No such file or directory" } }', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libcore/result.rs:837
stack backtrace:
   1:     0x56200f808a8a - std::sys::imp::backtrace::tracing::imp::write::h3188f035833a2635
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:42
   2:     0x56200f80d2df - std::panicking::default_hook::{{closure}}::h6385b6959a2dd25b
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:349
   3:     0x56200f80cede - std::panicking::default_hook::he4f3b61755d7fa95
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:365
   4:     0x56200f80d727 - std::panicking::rust_panic_with_hook::hf00b8130f73095ec
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:553
   5:     0x56200f80d564 - std::panicking::begin_panic::h6227f62cb2cdaeb4
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:515
   6:     0x56200f80d4d9 - std::panicking::begin_panic_fmt::h173eadd80ae64bec
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:499
   7:     0x56200f80d467 - rust_begin_unwind
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:475
   8:     0x56200f8352dd - core::panicking::panic_fmt::h3b2d1e30090844ff
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libcore/panicking.rs:69
   9:     0x56200f72dc1b - core::result::unwrap_failed::h822856a25f2ebc35
  10:     0x56200f736f3f - cargo_update::ops::get_index_path::hb01fd92f7e762dee
  11:     0x56200f72aa6d - cargo_install_update::main::h0b58adf594a61d40
  12:     0x56200f8145ba - __rust_maybe_catch_panic
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libpanic_unwind/lib.rs:98
  13:     0x56200f80de66 - std::rt::lang_start::h65647f6e36cffdae
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:434
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panic.rs:351
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/rt.rs:57
  14:     0x7f4de35222b0 - __libc_start_main
  15:     0x56200f7280c9 - _start
  16:                0x0 - <unknown>

Now, I don't understand the code, but it does seem strange to me—install.root in ~/.cargo/config should be equivalent to CARGO_INSTALL_ROOT environment, so I would have expected them to be processed mostly together.

nabijaczleweli added a commit that referenced this issue Feb 21, 2017
@nabijaczleweli
Copy link
Owner

Assuming that by "should be equivalent" means it just relocates the .crates.toml file w/o relocating the registry, check the fix/23-install.root branch, maybe?

@jan-hudec
Copy link
Author

Assuming that by "should be equivalent" means it just relocates the .crates.toml file w/o relocating the registry

precisely

check the fix/23-install.root branch, maybe?

$ cargo install-update -a -l
    Updating registry `https://github.com/rust-lang/crates.io-index`

Package        Installed      Latest   Needs update
cargo-release  v0.7.0-beta.3  v0.7.0   Yes
git-series     v0.9.1         v0.9.1   No
cargo-license  v0.1.2         v0.1.2   No
cargo-tree     v0.10.1        v0.10.1  No
cargo-modules  v0.3.2         v0.3.2   No
cargo-show     v0.2.2         v0.2.2   No
bindgen        v0.22.0        v0.22.0  No
ripgrep        v0.4.0         v0.4.0   No
cargo-readme   v1.1.0         v1.1.0   No

$ cargo install-update -a   
    Updating registry `https://github.com/rust-lang/crates.io-index`

Package        Installed      Latest   Needs update
cargo-release  v0.7.0-beta.3  v0.7.0   Yes
git-series     v0.9.1         v0.9.1   No
cargo-license  v0.1.2         v0.1.2   No
cargo-tree     v0.10.1        v0.10.1  No
cargo-modules  v0.3.2         v0.3.2   No
cargo-show     v0.2.2         v0.2.2   No
bindgen        v0.22.0        v0.22.0  No
ripgrep        v0.4.0         v0.4.0   No
cargo-readme   v1.1.0         v1.1.0   No

Updating cargo-release
    Updating registry `https://github.com/rust-lang/crates.io-index`
 Downloading cargo-release v0.7.0
   Compiling vec_map v0.6.0
   Compiling winapi v0.2.8
   Compiling utf8-ranges v0.1.3
   Compiling bitflags v0.7.0
   Compiling regex-syntax v0.3.9
   Compiling winapi-build v0.1.1
   Compiling unicode-width v0.1.4
   Compiling quick-error v0.1.4
   Compiling toml v0.1.30
   Compiling libc v0.2.20
   Compiling nom v1.2.4
   Compiling unicode-segmentation v1.1.0
   Compiling ansi_term v0.9.0
   Compiling kernel32-sys v0.2.2
   Compiling strsim v0.6.0
   Compiling term_size v0.2.3
   Compiling memchr v0.1.11
   Compiling thread-id v2.0.0
   Compiling aho-corasick v0.5.3
   Compiling thread_local v0.2.7
   Compiling semver v0.2.3
   Compiling clap v2.20.5
   Compiling regex v0.1.80
   Compiling cargo-release v0.7.0
    Finished release [optimized] target(s) in 33.5 secs
   Replacing /home/bulb/.local/bin/cargo-release


Updated 1 package.

Looks good.

@nabijaczleweli
Copy link
Owner

Released in v0.7.1

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

No branches or pull requests

2 participants