Comments (14)
Hey, it works! (With a cargo vendor
directory and manual :dep
calls.)
Also works with only the single :dep rand
call.
Also works when I switch to the Nix-produced vendor dir. 🎉
from evcxr.
One more question if you don't mind -- is there any actual difference between
init.evcxr
andprelude.rs
? I can't really tell from the docs. It seems you can put:
directives in either one. And they seem to both get executed after you input the first command in theevcxr
session?
There used to be a difference, but there isn't anymore. init.evcxr
used to only contain commands that were executed one at a time, whereas prelude.rs
contained code that was executed afterwards. But now they're basically the same. You're right that the docs on this could probably use some cleaning up.
from evcxr.
Awesome, thanks so much!
from evcxr.
P.S. In case it's relevant, I'm also setting CARGO_HOME
to a directory with the original Cargo.toml
/Cargo.lock
, as well as a .cargo/config.toml
file with some extra Cargo config like this:
[source.crates-io]
replace-with = "vendored-sources"
[source.vendored-sources]
local-registry = "/nix/store/.../some/index/path"
[net]
offline = true
from evcxr.
To debug this, I'd suggest setting EVCXR_TMPDIR=$HOME/tmp/e1
(or something like that), then running evcxr
. Once it fails, cd $EVCXR_TMPDIR
and try doing a cargo build
to see if it gives the same error. If it does, you can try editing Cargo.toml
to see what would be required to make it succeed.
from evcxr.
Something else I should mention is that adding lots of :dep
commands will make evcxr
startup pretty slow, since it will compile them all each time it starts - also rust-analzyer will analyse them all each time evcxr
starts.
If you're specifying a custom local registry, do you need to specify the path to the package? Assuming there's only one version in the registry, I'd expect that you could just write:
:dep rand
rand::random::<u8>()
from evcxr.
Thanks for the quick response! I tried the EVCXR_TMPDIR
thing and examined the Cargo.toml
after each step. After the first few deps (cfg-if
, wasi
, and libc
) they're all present:
after first 3 :dep calls
[package]
name = "ctx"
version = "1.0.0"
edition = "2021"
[lib]
crate-type = ["cdylib"]
path = "src/lib.rs"
[profile.dev]
opt-level = 2
debug = false
rpath = true
lto = false
debug-assertions = true
codegen-units = 16
panic = 'unwind'
incremental = true
overflow-checks = true
[dependencies]
wasi = { path = "/nix/store/44d4b4533ydszs27h6488w39sg3m7ivb-cargo-vendor-dir/wasi-0.11.0+wasi-snapshot-preview1" }
libc = { path = "/nix/store/44d4b4533ydszs27h6488w39sg3m7ivb-cargo-vendor-dir/libc-0.2.145" }
cfg-if = { path = "/nix/store/44d4b4533ydszs27h6488w39sg3m7ivb-cargo-vendor-dir/cfg-if-1.0.0" }
Then, after trying to add getrandom
, the Cargo.toml
changes abruptly and the other dependencies disappear:
after :dep getrandom call
[package]
name = "evcxr_dummy_validate_dep"
version = "0.0.1"
edition = "2021"
[lib]
path = "lib.rs"
[dependencies]
getrandom = { path = "/nix/store/44d4b4533ydszs27h6488w39sg3m7ivb-cargo-vendor-dir/getrandom-0.2.9" }
Reading between the lines here... is it possible that evcxr
is doing a "validation step" on each :dep
call where it produces a Cargo.toml
package called evcxr_dummy_validate_dep
with only that dependency? And then only if that succeeds does it add the dependency to the main file with package name ctx
?
If you're specifying a custom local registry, do you need to specify the path to the package?
I hope I can get it to work that way. I'll definitely try, probably after the basics are working with manual :dep
calls.
from evcxr.
Btw, would evcxr
work with normal cargo vendor
output instead? It produces output like this:
cargo vendor output
Vendoring cfg-if v1.0.0 (/home/tom/.cargo/registry/src/github.com-1ecc6299db9ec823/cfg-if-1.0.0) to /tmp/vendor2/cfg-if
Vendoring getrandom v0.2.10 (/home/tom/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.2.10) to /tmp/vendor2/getrandom
Vendoring libc v0.2.147 (/home/tom/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.147) to /tmp/vendor2/libc
Vendoring ppv-lite86 v0.2.17 (/home/tom/.cargo/registry/src/github.com-1ecc6299db9ec823/ppv-lite86-0.2.17) to /tmp/vendor2/ppv-lite86
Vendoring rand v0.8.5 (/home/tom/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.8.5) to /tmp/vendor2/rand
Vendoring rand_chacha v0.3.1 (/home/tom/.cargo/registry/src/github.com-1ecc6299db9ec823/rand_chacha-0.3.1) to /tmp/vendor2/rand_chacha
Vendoring rand_core v0.6.4 (/home/tom/.cargo/registry/src/github.com-1ecc6299db9ec823/rand_core-0.6.4) to /tmp/vendor2/rand_core
Vendoring wasi v0.11.0+wasi-snapshot-preview1 (/home/tom/.cargo/registry/src/github.com-1ecc6299db9ec823/wasi-0.11.0+wasi-snapshot-preview1) to /tmp/vendor2/wasi
To use vendored sources, add this to your .cargo/config.toml for this project:
[source.crates-io]
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "/tmp/vendor2"
I've tried to get this working by setting EVCXR_CONFIG_DIR
to point to a file with these configs, but no luck so far.
from evcxr.
Reading between the lines here... is it possible that
evcxr
is doing a "validation step" on each:dep
call where it produces aCargo.toml
package calledevcxr_dummy_validate_dep
with only that dependency? And then only if that succeeds does it add the dependency to the main file with package namectx
?
Yep, that's exactly what it does. The code that does that is here.
I assume when you cargo build
in $EVCXR_TMPDIR
that it fails to build? Assuming the failure is that it can't find cfg-if
, any idea why? Given that cfg-if
is in the vendored-sources, I would have hoped that it would find it.
I've tried to get this working by setting
EVCXR_CONFIG_DIR
to point to a file with these configs, but no luck so far.
EVCXR_CONFIG_DIR
is where evcxr
looks for its config (e.g. init.evcxr
) and doesn't affect where cargo
looks for its config.
from evcxr.
EVCXR_CONFIG_DIR is where evcxr looks for its config (e.g. init.evcxr) and doesn't affect where cargo looks for its config.
Oh I misspoke, I meant I set CARGO_HOME
to a directory with those configs.
from evcxr.
Oh I misspoke, I meant I set
CARGO_HOME
to a directory with those configs.
Ah, gotcha. Does setting CARGO_HOME
to point to those configs make it work when you cargo build
in EVCXR_TMPDIR
?
from evcxr.
Does setting CARGO_HOME to point to those configs make it work when you cargo build in EVCXR_TMPDIR?
I'm working on that now. I'm actually not seeing any sign that cargo
is picking up the configs at all, since it seems not to notice the net.offline
flag. I must be setting it up wrong somehow...
from evcxr.
Argh, it was supposed to be $CARGO_HOME/config.toml
instead of $CARGO_HOME/.cargo/config.toml
:P
Okay, making progress now.
from evcxr.
I'm slightly amazed it worked on the Nix vendor dir, because the folder name format is different (cfg-if-1.0.0
vs. cfg-if
).
But I'm happy, thanks for the help!
One more question if you don't mind -- is there any actual difference between init.evcxr
and prelude.rs
? I can't really tell from the docs. It seems you can put :
directives in either one. And they seem to both get executed after you input the first command in the evcxr
session?
from evcxr.
Related Issues (20)
- Reducing startup time by reusing the pre-compiled directory. HOT 6
- println! does not preserve the order of lines HOT 4
- Output error with comment. HOT 2
- Out of order print in the output HOT 4
- New name proposal: Ruins (RUst INteractive Shell) HOT 5
- Hashbrown's `HashMap::get` returns `None` although the key exists HOT 14
- `init.evcxr` and `prelude.rs` placed in the suggested MacOS location doesn't seem to do anything HOT 2
- Listing current REPL deps and manifest from within REPL? HOT 1
- printing colored outputs in the repl? HOT 3
- Double Ctrl-C killing repl unexpectedly HOT 1
- is sccache working properly? HOT 2
- Recompiling each time after I restart the kernel in Linux. HOT 4
- Is it possible to print out the documentation? HOT 7
- The error doesn't print as expected. HOT 2
- not compatible with latest rust 1.72.0 HOT 8
- Cached tokio runtime after panic HOT 1
- Cannot configure (persist) logging configuration HOT 38
- Rust kernel can't work HOT 3
- Slow execution speed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from evcxr.