Coder Social home page Coder Social logo

runner's Introduction

Running Little Rust Snippets

Leaving the Comfort (and Restrictions) of Cargo

Cargo is a good, reliable way to build programs and libraries in Rust with versioned dependencies. Those of us who have worked with the Wild West practices of C++ development find this particularly soothing, and it's one of the core strengths of the Rust ecosystem.

However, it's not intended to make running little test programs straightforward - you have to create a project with all the dependencies you wish to play with, and then edit src/main.rs and do cargo run. A useful tip is to create a src/bin directory containing your little programs and then use cargo run --bin NAME to run them. But there is a better way; if you have such a project (say called 'cache') then the following invocation will compile and link a program against those dependencies (rustc is an unusually intelligent compiler)

$ rustc -L /path/to/cache/target/debug/deps mytest.rs

Of course, you need to manually run cargo build on your cache project whenever new dependencies are added, or when the compiler is updated.

The runner tool helps to automate this pattern. It also supports snippets, which are little 'scripts' formatted like Rust documentation examples.

$ cat print.rs
println!("Hello, World!");

$ runner print.rs
Hello, World!

This follows basically the same rules as the doc-test snippets you find in Rust documentation, so runner allows you to copy those snippets into an editor and directly run them (I bind 'run' for Rust projects to runner ... in my favourite editor.)

You can use ? in snippets instead of the ubiquitous and awful unwrap, since the boilerplate encloses code in a function that returns Result<(),Box<Error+Sync+Send>> which is compatible with any error return.

A special variable args is available containing any arguments passed to the program:

$ cat hello.rs
println!("hello {}",args[1]);
$ runner hello.rs dolly
hello dolly

You can even - on Unix platforms - add a 'shebang' line to invoke runner:

$ cat hello
#!/usr/bin/env runner
println!("Hello, World!");

$ ./hello
Hello, World!

runner adds the necessary boilerplate and creates a proper Rust program in ~/.cargo/.runner/bin, prefixed with a prelude, which is initially:

#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(dead_code)]
#![allow(unused_macros)]
use std::{fs,io,env};
use std::fs::File;
use std::io::prelude::*;
use std::path::{PathBuf,Path};
use std::collections::HashMap;
use std::time::Duration;
use std::thread;

macro_rules! debug {
    ($x:expr) => {
        println!("{} = {:?}",stringify!($x),$x);
    }
}

After first invocation of runner, this is found in ~/.cargo/.runner/prelude; you can edit it later with runner --edit-prelude.

debug! saves typing: debug!(my_var) is equivalent to println!("my_var = {:?}",my_var).

As an experimental feature, runner will also do some massaging of rustc errors. They are usually very good, but involve fully qualified type names. It reduces std:: references to something simpler.

This is a snippet which a Java programmer would find easy to write - declare that type explicitly, and assume that the important verb is "set":

$ cat testm.rs
let mut map: HashMap<String,String> = HashMap::new();
map.set("hello","dolly");
$  runner testm.rs
error[E0599]: no method named `set` found for type `HashMap<String, String>` in the current scope
  --> /home/steve/.cargo/.runner/bin/testm.rs:24:9
   |
24 |     map.set("hello","dolly");
   |         ^^^
   |
   = help: did you mean `get`?

Since we are being very informal with Rust here, it's appropriate that we don't wish the type spelled out in full glory (as you can see by running with -S): std::collections::HashMap<std::string::String, std::string::String>.

Adding External Crates

As you can see, runner is very much about playing with small code snippets. By default it links the snippet dynamically which is significantly faster.

The static option is much more convenient. You can easily create a static cache with some common crates:

$ runner --add "time json regex"

You can add as many crates if you like - number of available dependencies doesn't slow down the linker. Thereafter, you may refer to these crates in snippets. Note that by default, runner uses 2018 edition since 0.4.0.

// json.rs
use json;

let parsed = json::parse(r#"

{
    "code": 200,
    "success": true,
    "payload": {
        "features": [
            "awesome",
            "easyAPI",
            "lowLearningCurve"
        ]
    }
}

"#)?;

println!("{}",parsed);

And then build statically and run (any extra arguments are passed to the program.)

$ runner -s json.rs
{"code":200,"success":true,"payload":{"features":["awesome","easyAPI","lowLearningCurve"]}}

A convenient new feature is "argument lines" - if the first line of json.rs was

//: -s

then any runner arguments specified after "//:" will be merged in with the command-line arguments. It is now possible to simply invoke using runner json.rs. It's better to keep any special build instructions in the file itself, and it means that an editor run action bound to runner FILE can be made to work in all cases.

runner provides various utilities for managing the static cache. You can say runner --edit to edit the static cache Cargo.toml, and runner --build to rebuild the cache afterwards. runner update will update all the dependencies in the cache, and runner update package will update a particular package - follow this with build as before.

The cache is built for both debug and release mode, so using -sO you can build snippets in release mode. Documentation is also built for the cache, and runner --doc will open that documentation in the browser. (It's always nice to have local docs, especially in bandwidth-starved situations.)

If you want docs for a specific crate NAME, then runner --doc NAME will work. Remember that the Rust documentation generated has a fast offline searchable index!

The --crates command also has an optional argument; without arguments it lists all he crates known to runner, with their versions. With a name, it uses an exact match:

$ runner --crates yansi
yansi = "0.3.4"

You may provide a number of crate names here; if --verbose (-v) is specified then the dependencies of these crates are also listed.

The -c flag only compiles the program or snippet, and copies it to ~/.cargo/bin. -r only runs the program, which must have previously been compiled, either explicitly with -c or implicitly with default operation.

Plain Rust source files (which already have fn main) are of course supported, but you will need the --extern (-x) flag to bring in any external crates from the static cache.

A useful trick - if you want to look at the Cargo.toml of an already downloaded crate to find out dependencies and features, then this command will open it for you:

favorite-editor $(runner -P some-crate)/Cargo.toml

Rust on the Command-line

There are a few Perl-inspired features. The -e flag compiles and evaluates an expression. You can use it as an unusually strict desktop calculator:

$ runner -e "10 + 20*4.5"
error[E0277]: the trait bound `{integer}: Mul<{float}>` is not satisfied
  --> temp/tmp.rs:20:22
   |
20 |     let res = 10 + 20*4.5;
   |                      ^ no implementation for `{integer} * {float}`

Likewise, you have to say 1.2f64.sin() because 1.2 has ambiguous type.

(Note that the trait std::ops::Mul is presented in simplified form by default)

--expression is very useful if you quickly want to find out how Rust will evaluate an expression - we do a debug print for maximum flexibility.

$ runner -e 'PathBuf::from("bonzo.dog").extension()'
Some("dog")

(This works because we have a use std::path::PathBuf in the runner prelude.)

Now, this will not work on Windows since quoting is seriously baroque. So runner re-uses an old trick that some Windows versions of AWK used. We can only use double-quotes for an argument that may contain spaces, but single-quotes within this will be converted to double-quotes.

c:> runner -e "PathBuf::from('bonzo.dog').extension()"
Some("dog")

So, in these examples where you need to quote strings in the Rust expression, remember that it works the other way in Windows.

-i (or --iterator) evaluates iterator expressions and does a debug dump of the results:

$ runner -i '(0..5).map(|i| (10*i,100*i))'
(0, 0)
(10, 100)
(20, 200)
(30, 300)
(40, 400)

Any extra command-line arguments are available for these commands, so:

$ runner -i 'env::args().enumerate()' one 'two 2' 3
(0, "/home/steve/.cargo/.runner/bin/tmp")
(1, "one")
(2, "two 2")
(3, "3")

And finally -n (or --lines) evaluates the expression for each line in standard input:

$ echo "hello there" | runner -n 'line.to_uppercase()'
"HELLO THERE"

The -x flag (--extern) allows you to insert an extern crate into your snippet. This is particularly useful for these one-line shortcuts. For example, my easy-shortcuts crate has a couple of helper functions. Before running these examples, first runner --add easy-shortcuts to load it into the static crate, and then runner -C easy-shortcuts to dynamically compile it.

$ runner -xeasy_shortcuts -e 'easy_shortcuts::argn_err(1,"gimme an arg!")' 'an arg'
"an arg"
$ runner -xeasy_shortcuts -e 'easy_shortcuts::argn_err(1,"gimme an arg!")'
/home/steve/.cargo/.runner/bin/tmp error: no argument 1: gimme an arg!

This also applies to --iterator:

$ runner -xeasy_shortcuts -i 'easy_shortcuts::files(".")'
"json.rs"
"print.rs"

With long crate names like this, you can define aliases:

$ runner --alias es=easy_shortcuts
$ runner -xes -e 'es::argn_err(1,"gimme an arg!")'
...

By default, runner -e does a dynamic link, and there are known limitations. By also using --static, you can evaluate expressions against crates compiled as static libraries. So, assuming that we have time in the static cache (runner --add time will do that for you):

$ runner -s -xtime -e "time::now()"
Tm { tm_sec: 34, tm_min: 4, tm_hour: 9, tm_mday: 28, tm_mon: 6, tm_year: 117,
tm_wday: 5, tm_yday: 208, tm_isdst: 0, tm_utcoff: 7200, tm_nsec: 302755857 }

'-X' (--wild) is like -x except it brings all the crate's symbols into scope. Not something you would overdo in regular code, but it makes for shorter command lines - the last example becomes (note how short flags can be combined):

$ runner -sXtime -e "now()"
...

-M (--macro) is also like -x except it prepends the 'extern crate' with #[macro_use]. Consider the very cool r4 crate which provides list comprehensions. First load in the static cache with runner --add r4, and then we can say:

$ runner -s --macro r4 -i 'iterate![for x in 0..4; yield x]'
0
1
2
3

Small snippets like these are faster if the crates can be linked dynamically, so after runner -C r4 to build a shared library in the dynamic cast, you can run this without the -s.

$ runner -Xto_vec -Mr4 -e 'iterate![for i in 0..2; for j in 0..2; yield (i,j)].to_vec()'
[(0, 0), (0, 1), (1, 0), (1, 1)]

(At this point, the command-line is getting sufficiently complicated that you would be better off with a little snippet that you can edit in a proper editor.)

With -e,-n or -i, you can specify. some initial code with --prepend:

$  runner -p 'let nums=0..5' -i 'nums.clone().zip(nums.skip(1))'
(0, 1)
(1, 2)
(2, 3)
(3, 4)

If you can get away with dynamic linking, then runner can make it easy to test a module interactively. In this way you get much of the benefit of a fully interactive interpreter (a REPL):

$ cat universe.rs
pub fn answer() -> i32 {
    42
}
$ runner -C universe.rs
building crate 'universe' at universe.rs
$ runner -xuniverse -e "universe::answer()"
42

This provides a way to get to play with big predefined strings:

$ cat > text.rs
pub const TEXT: &str = "possibly very long string";
$ runner -C text.rs
building crate 'text' at text.rs
$ runner -Xtext -e 'TEXT.find("long")'
Some(14)

Compiling Rust Doc Examples

Consider the example for the filetime crate:

use std::fs;
use filetime::FileTime;

let metadata = fs::metadata("runner.rs").unwrap();

let mtime = FileTime::from_last_modification_time(&metadata);
println!("{}", mtime);

let atime = FileTime::from_last_access_time(&metadata);
assert!(mtime < atime);

// Inspect values that can be interpreted across platforms
println!("{}", mtime.seconds_relative_to_1970());
println!("{}", mtime.nanoseconds());

// Print the platform-specific value of seconds
println!("{}", mtime.seconds());

After runner --add filetime, this crate is in your static cache. And runner --doc filetime will give you its local documentation.

However, it can't be compiled directly, for the reason that use std::fs is already in the runner prelude.

So we need to say:

$ runner -s --no-prelude filetime.rs
1506778536.945440909s
1506778536
945440909
1506778536

Or if you're in a hurry: runner -sN filetime.rs.

As always, can always put these arguments in a first comment like so "//: -sN".

Dymamic Compilation of Crates

It would be good to provide such an experience for the dynamic-link case, since it is faster. There is in fact a dynamic cache as well but support for linking against external crates dynamically is very basic. It works fine for crates that don't have any external depdendencies, e.g. this creates a libjson.so in the dynamic cache:

$ runner -C json

And then you can run the json.rs example without -s.

The --compile action takes three kinds of arguments:

  • a crate name that is already loaded and known to Cargo
  • a Cargo directory
  • a Rust source file - the crate name is the file name without extension.

Dynamic linking is not a priority for Rust tooling at the moment. So we have to build more elaborate libraries without the help of Cargo. (The following assumes that you have already brought in regex for a Cargo project, so that the Cargo cache is populated, e.g. with runner --add regex)

runner -C memchr
runner -C aho-corasick
runner -C utf8-ranges
runner -C lazy_static
runner -xlazy_static -C thread_local
runner -C regex-syntax
runner -C regex

This script drives home how tremendously irritating life in Rust would be without Cargo. We have to track the dependencies, ensure that the correct default features are enabled in the compilation, and special-case crates which directly link to libc.

However, the results feel worthwhile. Compiling the first regex documented example:

use regex::Regex;
let re = Regex::new(r"^\d{4}-\d{2}-\d{2}$").unwrap();
assert!(re.is_match("2014-01-01"));

With a static build (-s) I get 0.56s on this machine, and 0.25s with dynamic linking.

There are limitations to dynamic linking currently - crates which are "no std" (and don't provide a feature to turn this off) cannot be compiled. Also, remember that all invocations of runner -C end up with shared libraries placed in one directory called the 'dynamic cache' - there can only be one crate called 'libs' for example.

runner's People

Contributors

dwijnand avatar mbartlett21 avatar stevedonovan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

runner's Issues

autobuild dependencies

ivan@arch ~> runner -C regex
building crate 'regex' aho-corasick default memchr perf perf-cache perf-dfa perf-inline perf-literal std thread_local unicode unicode-age unicode-bool unicode-case unicode-gencat unicode-perl unicode-script unicode-segment at /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-1.3.9/src/lib.rs
error[E0463]: can't find crate for `aho_corasick`
   --> /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-1.3.9/src/lib.rs:624:1
    |
624 | extern crate aho_corasick;
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.

ivan@arch ~> runner add aho_corasick
runner error: no .rs file
ivan@arch ~ [1]> runner --add aho_corasick
    Updating crates.io index
error: no matching package named `aho_corasick` found
location searched: registry `https://github.com/rust-lang/crates.io-index`
perhaps you meant: aho-corasick
required by package `static-cache v0.1.0 (/home/ivan/.cargo/.runner/static-cache)`
Error occurred - restoring Cargo.toml
ivan@arch ~> runner --add aho-corasick
   Compiling static-cache v0.1.0 (/home/ivan/.cargo/.runner/static-cache)
    Finished dev [unoptimized + debuginfo] target(s) in 0.25s
   Compiling static-cache v0.1.0 (/home/ivan/.cargo/.runner/static-cache)
    Finished release [optimized] target(s) in 0.18s
 Documenting static-cache v0.1.0 (/home/ivan/.cargo/.runner/static-cache)
    Finished dev [unoptimized + debuginfo] target(s) in 1.55s
ivan@arch ~> runner -C regex
building crate 'regex' aho-corasick default memchr perf perf-cache perf-dfa perf-inline perf-literal std thread_local unicode unicode-age unicode-bool unicode-case unicode-gencat unicode-perl unicode-script unicode-segment at /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-1.3.9/src/lib.rs
error[E0463]: can't find crate for `aho_corasick`
   --> /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-1.3.9/src/lib.rs:624:1
    |
624 | extern crate aho_corasick;
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.

ivan@arch ~> runner -C aho-corasick
building crate 'aho_corasick' default std at /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/aho-corasick-0.7.13/src/lib.rs
error[E0463]: can't find crate for `memchr`
   --> /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/aho-corasick-0.7.13/src/lib.rs:189:1
    |
189 | extern crate memchr;
    | ^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.

ivan@arch ~> runner -C memchr
building crate 'memchr' default std use_std at /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/memchr-2.3.3/src/lib.rs
ivan@arch ~> runner -C aho-corasick
building crate 'aho_corasick' default std at /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/aho-corasick-0.7.13/src/lib.rs
ivan@arch ~> runner -C regex
building crate 'regex' aho-corasick default memchr perf perf-cache perf-dfa perf-inline perf-literal std thread_local unicode unicode-age unicode-bool unicode-case unicode-gencat unicode-perl unicode-script unicode-segment at /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-1.3.9/src/lib.rs
error[E0463]: can't find crate for `regex_syntax`
   --> /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-1.3.9/src/lib.rs:632:1
    |
632 | extern crate regex_syntax as syntax;
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.

ivan@arch ~> runner -C regex-syntax
building crate 'regex_syntax' default unicode unicode-age unicode-bool unicode-case unicode-gencat unicode-perl unicode-script unicode-segment at /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-syntax-0.6.18/src/lib.rs
ivan@arch ~> runner -C regex
building crate 'regex' aho-corasick default memchr perf perf-cache perf-dfa perf-inline perf-literal std thread_local unicode unicode-age unicode-bool unicode-case unicode-gencat unicode-perl unicode-script unicode-segment at /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-1.3.9/src/lib.rs
error[E0463]: can't find crate for `thread_local`
   --> /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-1.3.9/src/lib.rs:634:1
    |
634 | extern crate thread_local;
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.

ivan@arch ~> runner -C thread-local
runner error: no .rs file
ivan@arch ~ [1]> runner -C thread_local
building crate 'thread_local'  at /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/thread_local-1.0.1/src/lib.rs
error[E0463]: can't find crate for `lazy_static`
  --> /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/thread_local-1.0.1/src/lib.rs:74:1
   |
74 | extern crate lazy_static;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.

ivan@arch ~> runner -C lazy-static
runner error: no .rs file
ivan@arch ~ [1]> runner -C lazy_static
building crate 'lazy_static'  at /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.4.0/src/lib.rs
ivan@arch ~> runner -C regex
building crate 'regex' aho-corasick default memchr perf perf-cache perf-dfa perf-inline perf-literal std thread_local unicode unicode-age unicode-bool unicode-case unicode-gencat unicode-perl unicode-script unicode-segment at /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-1.3.9/src/lib.rs
error[E0463]: can't find crate for `thread_local`
   --> /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-1.3.9/src/lib.rs:634:1
    |
634 | extern crate thread_local;
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.

ivan@arch ~> runner -C thread_local
building crate 'thread_local'  at /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/thread_local-1.0.1/src/lib.rs
ivan@arch ~> runner -C regex
building crate 'regex' aho-corasick default memchr perf perf-cache perf-dfa perf-inline perf-literal std thread_local unicode unicode-age unicode-bool unicode-case unicode-gencat unicode-perl unicode-script unicode-segment at /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-1.3.9/src/lib.rs

Trial and error to install regex, took quite an effort, maybe we can just do this with --add?

Install instructions

Is there a rustup install option or the binary need to built and copied to /bin?

Adding crate a second time emits error but no exit code

If the same crate is added twice, the second time there is no exit-code

runner --add flagset
error: failed to parse manifest at `/Users/john.vandenberg/.cargo/.runner/static-cache/Cargo.toml`

Caused by:
  could not parse input as TOML

Caused by:
  duplicate key: `flagset` for key `dependencies` at line 9 column 1
Error occurred - restoring Cargo.toml

It would be nicer for scripting if runner --add flagset some.rs would add flagset if it is missing, and then run some.rs.

Newlines in --prepend

I'm having a bit of trouble with --prepend:

echo -e 'let a = 3;\nprintln!("{}", a + 2);' > mwe.rs

If I run

runner --prepend "// pre\n" mwe.rs

then I get an error. I think that's because there is no newline after the prefix, which means the first line gets swallowed by a comment. It seems Bash likes swallowing trailing whitespace.

24 |     println!("{}", a + 2);
   |                    ^ not found in this scope

Maybe either or both of these solutions could be applied:

  • Put a newline after the prepended text by default (easy and avoids mistakes, but doesn't allow newlines in the prepend text).
  • Replace any "\n" by a real newline. Convenient for adding any newline anywhere despite shell escaping.

add support for input from terminal stdin

Is it possible to add support for input from terminal stdin like below?

runner --add time <<'EOF'
use time;
fn main(){
  println!("I'm from stdin! {}", time::now().rfc822z());
}
EOF

That way it's very straight forward to experiment in the air without any file storage.

Problem with dynamic linking crate 'rand'

When I run this:

runner --add rand
echo "use rand;" > mwe.rs
runner mwe.rs

I get this error:

error: extern location for rand does not exist: /home/mark/.cargo/.runner/unstable/dy-cache/librand.so
error[E0463]: can't find crate for `rand`
  --> /home/user/.cargo/.runner/unstable/bin/mwe.rs:20:5
   |
20 | use rand;
   |     ^^^^ can't find crate

I think the first line means there's something going wrong with linking. I tried with -s:

runner -s mwe.rs

and indeed that works fine. I don't know how to solve it though.

P.s.: I like the tool, cool idea!

"Library not loaded" error

Hi, thank you for building and sharing this tool :)

I've encountered an error when I try to use runner, e.g. with simple example such as: runner -e 'String::from("Hello, World")'.

The error is:

dyld[36022]: Library not loaded: '@rpath/libstd-6d3bb15ae9e42a6c.dylib'
  Referenced from: '/Users/danielwaltrip/.cargo/.runner/bin/tmp'
  Reason: tried: '/usr/local/lib/libstd-6d3bb15ae9e42a6c.dylib' (no such file), '/usr/lib/libstd-6d3bb15ae9e42a6c.dylib' (no such file)

I was able to fix this by setting the ENV var DYLD_FALLBACK_LIBRARY_PATH like so:

export DYLD_FALLBACK_LIBRARY_PATH="$DYLD_FALLBACK_LIBRARY_PATH:$(rustc --print=sysroot)/lib"

I think I'll add this to my bash_rc or bash_profile... I'm good for now but just wanted to document the issue and what I've learned about it.

System / debug info

  • System Version: macOS 12.6 (21G115)
  • Kernel Version: Darwin 21.6.0
  • Chip: Apple M1 Max
  • rustc --version: rustc 1.68.2 (9eb3afe9e 2023-03-27)
  • cargo --version: cargo 1.68.2 (6feb7c9cf 2023-03-26)
  • rustup --version: rustup 1.25.2 (17db695f1 2023-02-01)

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.