Coder Social home page Coder Social logo

Comments (18)

nabijaczleweli avatar nabijaczleweli commented on August 26, 2024

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

Is the redirection thing documented somewhere?

from cargo-update.

jan-hudec avatar jan-hudec commented on August 26, 2024

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.

from cargo-update.

nabijaczleweli avatar nabijaczleweli commented on August 26, 2024

cool

from cargo-update.

nabijaczleweli avatar nabijaczleweli commented on August 26, 2024

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.

from cargo-update.

nabijaczleweli avatar nabijaczleweli commented on August 26, 2024

Released in v0.7.0

from cargo-update.

jan-hudec avatar jan-hudec commented on August 26, 2024

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).

from cargo-update.

nabijaczleweli avatar nabijaczleweli commented on August 26, 2024

Okay, what about install.root, then?

from cargo-update.

jan-hudec avatar jan-hudec commented on August 26, 2024

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

from cargo-update.

nabijaczleweli avatar nabijaczleweli commented on August 26, 2024

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

from cargo-update.

jan-hudec avatar jan-hudec commented on August 26, 2024

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.

from cargo-update.

nabijaczleweli avatar nabijaczleweli commented on August 26, 2024

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.

from cargo-update.

jan-hudec avatar jan-hudec commented on August 26, 2024
$ 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"]

from cargo-update.

nabijaczleweli avatar nabijaczleweli commented on August 26, 2024

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

from cargo-update.

nabijaczleweli avatar nabijaczleweli commented on August 26, 2024

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()

from cargo-update.

jan-hudec avatar jan-hudec commented on August 26, 2024

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.

from cargo-update.

nabijaczleweli avatar nabijaczleweli commented on August 26, 2024

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?

from cargo-update.

jan-hudec avatar jan-hudec commented on August 26, 2024

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.

from cargo-update.

nabijaczleweli avatar nabijaczleweli commented on August 26, 2024

Released in v0.7.1

from cargo-update.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.