1. 66

  2. 8

    That feels a little bit like going all-in after the complaints regarding rust in the python lib ;) Will be interesting to see how this experiment goes. And if nothing else shows us all the quirks one has to copy, to comply with current coreutils in the wild.

    1. 17

      It’s heartening to see a project that actually tries to rewrite stuff in Rust, instead of mostly advocating others do it.

      1. 0

        Good god the dependencies: https://github.com/uutils/coreutils/blob/master/Cargo.lock. Hopefully something like big stdlib (as in Python) or stl+boost (in C++) appears in rust. I bet coreutils can be written in Python without any dependencies, and in C++ with stl and boost.

        1. 22

          You’re looking at a computer generated file, which is easily over half self dependencies, and over a quarter about things like bench-marking tools, and the rest of it is mostly completely reasonable, and duplicated by dependencies organizing themselves into multiple crates (note that that file includes every transient dependency).

          If you want to see the actual lists of dependencies, cd into src and run rg '\[dependencies\]' -A20, and look for things under [dependencies] that don’t have path set (self dependencies).

          I’ll copy in some for you as an example, and annotate the first use of every dependency (note this is just the list of things that rg happened to spit out at the bottom for me)

          clap = "2.33"  # Command line parsing 
          chrono = "0.4.4" # Date time library
          clap = "2.33"
          clap = "2.33"
          libc = "0.2.42"  # Literally just libc bindings (maintained by core team)
          walkdir = "2.2" # Does what it says on the tin
          getopts = "0.2.18"   # Command line parsing
          getopts = "0.2.18"
          getopts = "0.2.18"
          libc = "0.2.42"
          proc-macro2 = "1.0" # Rust maintained crate for writing procedural macros
          quote = "1.0" # Rust maintained crate for writing procedural macros
          syn = { version="1.0" } # Rust maintained crate for writing procedural macros
          clap = "2.33"
          libc = ">= 0.2"
          1. 3

            Thanks for the reply. Can you explain, say I want to compile coreutils locally without any dev dependencies. What crates I should download (besides rust)?

            1. 7

              When you say locally, I assume you mean without internet (since cargo build downloads all dependencies and builds them locally by default), and without offline local caches that may or may not exist (which you can restrict cargo to using with --offline).

              What you should do is be lazy and run cargo vendor, which will happen to download dev dependencies too. Unfortunately there doesn’t seem to be a flag to exclude dev dependencies, probably if you added one they would accept it.

              If you’re just trying to get an idea what the dependency tree looks like, I recommend just running cargo tree -e normal.

              If for some reason you’re insistent on finding every recursive dependency by hand though, the following command should work. It lists all the dependencies in a tree, filters out self dependencies, selects just the dependency name + version, and then sorts + de-duplicates them. This is a pretty bad way to get an idea what the dependency tree looks like though.

              cargo tree -e normal | grep -v coreutils | egrep -o ' [a-z_-]+ v[^ ]+' | sort | uniq
              1. 1

                I assume you mean without internet Yes.


          2. 4

            Yeah, if you want someone to pile on, one could say some of the code is really dirty too. :) But I think it kinda makes sense to concentrate on compatibility with GNU coreutils first and only then root out unnecessary dependencies or increase performance or what not. All of those are much better suited to tackle after you have an existing test suite that just passes.

            1. 11

              FWIW, I believe the coreutils project started before Rust 1.0. If you thought Rust changed a lot now, you should have seen it before 1.0, especially in the months leading up to 1.0. Any code I wrote that survived that transformation became a complete and total mess.

              1. 1

                Yup, that’s also a very fair point. My comment above was in context of a conversation I had with Sylvestre earlier today and the diff at https://github.com/uutils/coreutils/commit/0a02aeda71c5faa1eb726deed69e7141bc20919d#diff-f27fff3d4fe45a009932c1fffaba0e58e6bb9fc085e22514e03c68d3d950dd4aR99, which I should have linked to. Oops :)

              2. 1

                Yeah, if you want someone to pile on, one could say some of the code is really dirty too. :)

                It really is a replacement for coreutils, then.