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

"Task not found" with workspace AND "root package" #644

Closed
tower120 opened this issue Apr 13, 2022 · 32 comments
Closed

"Task not found" with workspace AND "root package" #644

tower120 opened this issue Apr 13, 2022 · 32 comments
Assignees
Labels
Milestone

Comments

@tower120
Copy link

In crate with workspace AND "root package":

  • Calling cargo make build/test/etc. ignores "root package"
  • Calling cargo make 'task_name' (without CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE) results in "Task not found". Adding CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE ignores "root package".

Basic cargo build/test works fine.

See attachment.

@sagiegurari
Copy link
Owner

@tower120 thanks for reporting.
I think its due to misunderstanding on my part of the spec so i'll fix that.
if i only picked up members from the members attribute and dependencies.
root, i only took if no members were defined, but thats my issue, if package is defined, i need to add the root as well.
i'll fix that.

@sagiegurari
Copy link
Owner

@tower120 I just pushed a fix in the dev branch 0.35.11 and would love your feedback. can you try it out and tell if it works well?

@tower120
Copy link
Author

tower120 commented Apr 19, 2022

I'm unfamiliar with compiler crates. How can I build/apply it?

@sagiegurari
Copy link
Owner

you can look at this explanation https://doc.rust-lang.org/cargo/commands/cargo-install.html#synopsis
basically its
cargo install --git git@github.com:sagiegurari/cargo-make.git --branch 0.35.11

@tower120
Copy link
Author

tower120 commented Apr 19, 2022

Looks like the same error with project attached in issue.

@sagiegurari
Copy link
Owner

meaning its ignoring the 'root' package? can you show me the output please?

@tower120
Copy link
Author

PS C:\RustProjects\cargo_make_test> cargo install --git https://github.com/sagiegurari/cargo-make.git --branch 0.35.11
    Updating git repository `https://github.com/sagiegurari/cargo-make.git`
  Installing cargo-make v0.35.10 (https://github.com/sagiegurari/cargo-make.git?branch=0.35.11#ab70a4bb)
    Updating crates.io index
  Downloaded lenient_semver_parser v0.4.2
  Downloaded lenient_semver_version_builder v0.4.2
  Downloaded lenient_semver v0.4.2
  Downloaded 3 crates (351.9 KB) in 1.02s
   Compiling winapi v0.3.9
   Compiling proc-macro2 v1.0.37
   Compiling cfg-if v1.0.0
   Compiling unicode-xid v0.2.2
   Compiling autocfg v1.1.0
   Compiling syn v1.0.91
   Compiling serde_derive v1.0.136
   Compiling serde v1.0.136
   Compiling libc v0.2.124
   Compiling memchr v2.4.1
   Compiling lazy_static v1.4.0
   Compiling ppv-lite86 v0.2.16
   Compiling encoding_index_tests v0.1.4
   Compiling version_check v0.9.4
   Compiling typenum v1.15.0
   Compiling winapi-build v0.1.1
   Compiling semver v1.0.7
   Compiling log v0.4.16
   Compiling regex-syntax v0.6.25
   Compiling dunce v1.0.2
   Compiling tinyvec_macros v0.1.0
   Compiling winapi v0.2.8
   Compiling fnv v1.0.7
   Compiling crc32fast v1.3.2
   Compiling itoa v1.0.1
   Compiling matches v0.1.9
   Compiling adler v1.0.2
   Compiling hashbrown v0.11.2
   Compiling serde_json v1.0.79
   Compiling unicode-bidi v0.3.7
   Compiling native-tls v0.2.10
   Compiling percent-encoding v2.1.0
   Compiling crossbeam-utils v0.8.8
   Compiling ryu v1.0.9
   Compiling utf8-ranges v0.1.3
   Compiling regex-syntax v0.3.9
   Compiling once_cell v1.10.0
   Compiling bytes v1.1.0
   Compiling camino v1.0.7
   Compiling os_str_bytes v6.0.0
   Compiling cpufeatures v0.2.2
   Compiling lazy_static v0.1.16
   Compiling either v1.6.1
   Compiling wildmatch v2.1.0
   Compiling nom v1.2.4
   Compiling whoami v1.2.1
   Compiling strsim v0.10.0
   Compiling num_cpus v1.13.1
   Compiling textwrap v0.15.0
   Compiling heck v0.4.0
   Compiling base64 v0.13.0
   Compiling bitflags v1.3.2
   Compiling fs_extra v1.2.0
   Compiling glob v0.3.0
   Compiling rust_info v0.3.2
   Compiling git_info v0.1.2
   Compiling getrandom v0.2.6
   Compiling encoding-index-tradchinese v1.20141219.5
   Compiling encoding-index-japanese v1.20141219.5
   Compiling encoding-index-korean v1.20141219.5
   Compiling encoding-index-simpchinese v1.20141219.5
   Compiling encoding-index-singlebyte v1.20141219.5
   Compiling num-traits v0.2.14
   Compiling num-integer v0.1.44
   Compiling num-iter v0.1.42
   Compiling indexmap v1.8.1
   Compiling kernel32-sys v0.2.2
   Compiling tinyvec v1.5.1
   Compiling generic-array v0.14.5
   Compiling miniz_oxide v0.5.1
   Compiling form_urlencoded v1.0.1
   Compiling thread_local v1.1.4
   Compiling clap_lex v0.1.1
   Compiling http v0.2.6
   Compiling meval v0.2.0
   Compiling rand_core v0.6.3
   Compiling encoding v0.2.33
   Compiling unicode-normalization v0.1.19
   Compiling rand_chacha v0.3.1
   Compiling quote v1.0.18
   Compiling aho-corasick v0.7.18
   Compiling bstr v0.2.17
   Compiling memchr v0.1.11
   Compiling which v4.2.5
   Compiling fern v0.6.1
   Compiling flate2 v1.0.23
   Compiling rand v0.8.5
   Compiling idna v0.2.3
   Compiling aho-corasick v0.5.3
   Compiling regex v1.5.5
   Compiling winapi-util v0.1.5
   Compiling schannel v0.1.19
   Compiling time v0.1.43
   Compiling atty v0.2.14
   Compiling dirs-sys-next v0.1.2
   Compiling home v0.5.3
   Compiling ansi_term v0.12.1
   Compiling crypto-common v0.1.3
   Compiling block-buffer v0.10.2
   Compiling url v2.2.2
   Compiling fsio v0.3.0
   Compiling same-file v1.0.6
   Compiling termcolor v1.1.3
   Compiling globset v0.4.8
   Compiling java-properties v1.4.1
   Compiling shell2batch v0.4.4
   Compiling colored v2.0.0
   Compiling dirs-next v2.0.0
   Compiling thread-id v2.0.0
   Compiling digest v0.10.3
   Compiling walkdir v2.3.2
   Compiling duckscript v0.7.1
   Compiling run_script v0.9.0
   Compiling num v0.1.42
   Compiling attohttpc v0.18.0
   Compiling thread_local v0.2.7
   Compiling sha2 v0.10.2
   Compiling ignore v0.4.18
   Compiling chrono v0.2.25
   Compiling regex v0.1.80
   Compiling ftp v3.0.1
   Compiling cargo-platform v0.1.2
   Compiling serde_ignored v0.1.2
   Compiling toml v0.5.9
   Compiling lenient_semver_version_builder v0.4.2
   Compiling envmnt v0.9.1
   Compiling clap v3.1.9
   Compiling lenient_semver_parser v0.4.2
   Compiling ci_info v0.14.4
   Compiling cargo_metadata v0.14.2
   Compiling duckscriptsdk v0.8.10
   Compiling lenient_semver v0.4.2
   Compiling cargo-make v0.35.10 (C:\Users\Andy\.cargo\git\checkouts\cargo-make-beee6198da581977\ab70a4b)
warning: unknown lint: `deprecated_cfg_attr_crate_type_name`
  --> src/lib/mod.rs:21:5
   |
21 |     deprecated_cfg_attr_crate_type_name,
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unknown_lints)]` on by default

warning: unknown lint: `duplicate_macro_attributes`
  --> src/lib/mod.rs:26:5
   |
26 |     duplicate_macro_attributes,
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: `cargo-make` (lib) generated 2 warnings
    Finished release [optimized] target(s) in 2m 57s
   Replacing C:\Users\Andy\.cargo\bin\cargo-make.exe
   Replacing C:\Users\Andy\.cargo\bin\makers.exe
    Replaced package `cargo-make v0.35.10` with `cargo-make v0.35.10 (https://github.com/sagiegurari/cargo-make.git?branch=0.35.11#ab70a4bb)` (executables `cargo-make.exe`, `makers.exe`)
PS C:\RustProjects\cargo_make_test> cargo make build-test-1
[cargo-make] INFO - cargo make 0.35.10
[cargo-make] INFO - Project: cargo_make_test
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: build-test-1
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: legacy-migration
[cargo-make] INFO - Running Task: workspace
C:\RustProjects\cargo_make_test
[cargo-make][1] INFO - Project: crate1
[cargo-make][1] INFO - Build File: Makefile.toml
[cargo-make][1] INFO - Task: build-test-1
[cargo-make][1] INFO - Profile: development
[cargo-make][1] ERROR - Task build-test-1 not found
[cargo-make][1] WARN - Build Failed.
[cargo-make] ERROR - Error while running duckscript: Source: Unknown Line: 4 - Error while executing command, exit code: 1
[cargo-make] WARN - Build Failed.

@tower120
Copy link
Author

Maybe my cargo-make not updated, because git's xxxx.11 is marked as xxxx.10 inside Crate.toml?

@sagiegurari
Copy link
Owner

I only update the version when i publish so thats ok.
is the test you are running the same as you attached initially? did you set the CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE?
if so i'll use it as a test to check

@tower120
Copy link
Author

tower120 commented Apr 19, 2022

I just downloaded issue attachment and tried with it, to double check. It is the same error I just wrote.

@tower120
Copy link
Author

CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE is not set in there

@sagiegurari
Copy link
Owner

ok that should be set since you want in the member to access a task that is defined in the root. right?

@tower120
Copy link
Author

I think no - since I don't want member tasks to be build through cargo-make process. Only root one. I want root crate to serve as lib hub.
See https://github.com/bevyengine/bevy project structure, for example.

@tower120
Copy link
Author

Or that was not the question? I just looked at doc - it looked like I didn't need CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE.

@sagiegurari
Copy link
Owner

let me explain a bit.
cargo-make checks the makefile.toml in the directory its invoked.
for workspace its invoked as child process for every member.
so in the member that is on different dir, it doesn't see the makefile in the workspace root.
in order to automatically 'extend' the root makefile, you need that env var defined.

i just took your example, uncommented that env var comment and made it used and it worked well.
however, since cargo-make is invoked also as child it will go to installed version so in order to really test it, you must install the current git version and not just run something locally.

@tower120
Copy link
Author

however, since cargo-make is invoked also as child it will go to installed version so in order to really test it, you must install the current git version and not just run something locally.

I did

cargo install --git https://github.com/sagiegurari/cargo-make.git --branch 0.35.11

Doesn't that install compiled git version?

I uncommented CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE - I still have the same error as above.

@sagiegurari
Copy link
Owner

@tower120 here is what i did. can you please check it and compare with your test?

  • Created new empty gitpod machine

  • Run installation and pull example:

cargo install --git https://github.com/sagiegurari/cargo-make.git --branch 0.35.11
mkdir -p ./tasknotfound
cd ./tasknotfound
wget https://github.com/sagiegurari/cargo-make/files/8484155/cargo_make_test.zip
unzip ./cargo_make_test.zip
cd ./cargo_make_test
  • manually uncomment CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE

  • run cargo make build-test-1

output:
see that member is invoked with task but fails on rustc setup which is ok, but task is found

cargo make build-test-1
[cargo-make] INFO - cargo make 0.35.10
[cargo-make] INFO - Project: cargo_make_test
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: build-test-1
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: legacy-migration
[cargo-make] INFO - Running Task: workspace
/workspace/misc-test/tasknotfound/cargo_make_test
[cargo-make][1] INFO - Project: crate1
[cargo-make][1] INFO - Build File: Makefile.toml
[cargo-make][1] INFO - Task: build-test-1
[cargo-make][1] INFO - Profile: development
[cargo-make][1] INFO - Skipping Task: legacy-migration 
[cargo-make][1] INFO - Running Task: build-test-1
   Compiling crate1 v0.1.0 (/workspace/misc-test/tasknotfound/cargo_make_test/crates/crate1)
error[E0463]: can't find crate for `std`
  |
  = note: the `x86_64-pc-windows-msvc` target may not be installed
  = help: consider downloading the target with `rustup target add x86_64-pc-windows-msvc`

For more information about this error, try `rustc --explain E0463`.
error: could not compile `crate1` due to previous error
[cargo-make][1] ERROR - Error while executing command, exit code: 101
[cargo-make][1] WARN - Build Failed.
[cargo-make] ERROR - Error while running duckscript: Source: Unknown Line: 4 - Error while executing command, exit code: 1
[cargo-make] WARN - Build Failed.
  • create some test task in root makefile toml
[tasks.echo]
command = "echo"
args = ["current member: ${CARGO_MAKE_CRATE_CURRENT_WORKSPACE_MEMBER}"]

The output was:

cargo make echo
[cargo-make] INFO - cargo make 0.35.10
[cargo-make] INFO - Project: cargo_make_test
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: echo
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: legacy-migration
[cargo-make] INFO - Running Task: workspace
/workspace/misc-test/tasknotfound/cargo_make_test
[cargo-make][1] INFO - Project: crate1
[cargo-make][1] INFO - Build File: Makefile.toml
[cargo-make][1] INFO - Task: echo
[cargo-make][1] INFO - Profile: development
[cargo-make][1] INFO - Skipping Task: legacy-migration 
[cargo-make][1] INFO - Execute Command: "echo" "current member: crate1"
current member: crate1
[cargo-make][1] INFO - Build Done in 0.20 seconds.
[cargo-make][1] INFO - Project: cargo_make_test
[cargo-make][1] INFO - Build File: Makefile.toml
[cargo-make][1] INFO - Task: echo
[cargo-make][1] INFO - Profile: development
[cargo-make][1] INFO - Skipping Task: legacy-migration 
[cargo-make][1] INFO - Execute Command: "echo" "current member: ."
current member: .
[cargo-make][1] INFO - Build Done in 0.21 seconds.
[cargo-make] INFO - Build Done in 0.79 seconds.

as you can see both member '.' (root) and crate1 were invoked.

@tower120
Copy link
Author

Looks like you repeat my steps, but result is different on my local machine.
I uncommened CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE. And tried to add tasks.echo - it does not see that task too.

Could you increase crate version number in dev branch? I have filling that somehow crates.io version is still in use.

@sagiegurari
Copy link
Owner

@tower120 you can fork that branch to you and update it and than install it from your fork.

@tower120
Copy link
Author

tower120 commented Apr 21, 2022

I tried to increase version and install. Still no luck.
You know - maybe this is something on my side indeed - I just don't see it.

@sagiegurari
Copy link
Owner

try to use 'which' to see which cargo-make executable is used and see where cargo install pushes it. maybe its different places

@tower120
Copy link
Author

tower120 commented Apr 21, 2022

try to use 'which' to see which cargo-make executable is used and see where cargo install pushes it. maybe its different places

How? I'm on Windows. For example:

> where.exe cargo-make
C:\Users\Andy\.cargo\bin\cargo-make.exe

@sagiegurari
Copy link
Owner

oh, windows :). so try to delete it, and run it and see if it fails (it should). then install again.

@tower120
Copy link
Author

Unistalled then installed. No effect - still ERROR - Task echo not found.

@sagiegurari
Copy link
Owner

so maybe i got a bug on windows?
hard to say. try to put verbose logs and redirect to file and attach it as a file or something. it will be big.

@tower120
Copy link
Author

Just FYI - I already migrated to powershell script.

cargo make --verbose echo

@sagiegurari
Copy link
Owner

ok, something is strange to me here...
you are running it from C:\tmp\bevy_test right?
in the Cargo.toml there you have dependency: "../bevy"?
I think at the moment, its not detecting it as a workspace. are these 2 folders defined under a same workspace?

@sagiegurari sagiegurari added this to the 0.35.11 milestone Apr 21, 2022
@sagiegurari
Copy link
Owner

per the spec, in order to bevy_test to be considered workspace root, it must have the [workspace] tag
https://doc.rust-lang.org/cargo/reference/workspaces.html#root-package
so i'm just wondering how the structure is of the project exactly

@tower120
Copy link
Author

Damn, sorry. I tried that with a wrong project.
It turns out that it working.

@sagiegurari
Copy link
Owner

great news. i was worried I got more 'windows' specific issues since i don't have windows to try it on..... so happy its resolved.
i'm hoping to officially release it soon

@sagiegurari
Copy link
Owner

@tower120 this is now officially released.

@tower120
Copy link
Author

Great! Thanks!

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

No branches or pull requests

2 participants