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

Clap install-binary fail #1111

Open
tracyone opened this issue Jan 26, 2025 · 9 comments
Open

Clap install-binary fail #1111

tracyone opened this issue Jan 26, 2025 · 9 comments
Labels
bug Something isn't working

Comments

@tracyone
Copy link

_Instructions:`Clap install-binary

Environment (please complete the following information):

  • OS: MacOS 12.7.6
  • vim-clap version: latest
  • Have you reproduced with a minimal vimrc: no
  • Have you updated to the latest plugin version: yes
  • Have you upgraded to/compiled the latest Rust binary: yes

Describe the bug

   Compiling which v5.0.0
error[E0658]: exclusive range pattern syntax is experimental
   --> crates/utils/src/io.rs:166:13
    |
166 |             1..SMALL_FILE_THRESHOLD => FileSizeTier::Small,
    |             ^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
    = help: use an inclusive range pattern, like N..=M

error[E0658]: exclusive range pattern syntax is experimental
   --> crates/utils/src/io.rs:167:13
    |
167 |             SMALL_FILE_THRESHOLD..MEDIUM_FILE_THRESHOLD => FileSizeTier::Medium,
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
    = help: use an inclusive range pattern, like N..=M

For more information about this error, try `rustc --explain E0658`.
error: could not compile `utils` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...

Clap debug

Image

To Reproduce

Clap install-binary

@tracyone tracyone added the bug Something isn't working label Jan 26, 2025
@liuchengxu
Copy link
Owner

It should be fixed in the latest commit of the master. Please pull and re-run :Clap install-binary.

@tracyone
Copy link
Author

Image

@liuchengxu
Copy link
Owner

Hmm, please run rustup run 1.83 cargo build --release directly from your terminal, let me know if this works.

@tracyone
Copy link
Author

ustup run 1.83 cargo build --release
error: toolchain '1.83-x86_64-apple-darwin' is not installed

Do I need to install "1.83-x86_64-apple-darwin"?

liuchengxu added a commit that referenced this issue Jan 27, 2025
@liuchengxu
Copy link
Owner

Yes, the compilation error you encountered in the initial comment is because of using an earlier Rust version (expect 1.83, but 1.79 is used instead). Just pushed another commit to try installing the missing toolchain automatically, please try again. If the problem persists, try to run cargo build --release from the root of the repo directly, rustup is supposed to install the missing toolchain automatically.

@tracyone
Copy link
Author

Image

Something is wrong when execute Clap install-binary after update vim-clap

@liuchengxu
Copy link
Owner

liuchengxu commented Jan 27, 2025

If the problem persists, try to run cargo build --release from the root of the repo directly, rustup is supposed to install the missing toolchain automatically.

The Vimscript API is nothing but a convenient way to invoke the cargo command on your system. Please make sure the binary can be compiled successfully on your system first, fixing the API is easy afterward.

UPD: the error in your last comment can be fixed by this patch:

diff --git a/autoload/clap/installer.vim b/autoload/clap/installer.vim
index 446ff68d..eb7bc622 100644
--- a/autoload/clap/installer.vim
+++ b/autoload/clap/installer.vim
@@ -117,7 +117,7 @@ function! clap#installer#build_maple() abort
     endif
 
     if empty(filter(split(system('rustup toolchain list')), 'v:val =~ l:rust_version'))
-      let cmd = printf('rustup install %s && cargo +%s build --release', rust_version)
+      let cmd = printf('rustup install %s && cargo +%s build --release', rust_version, rust_version)
     else
       let cmd = printf('cargo +%s build --release', rust_version)
     endif

@tracyone
Copy link
Author

  1. term_start can not recognize "&&", so we use: &shell -c
  2. Cargo does not handle +toolchain directives. so we use: rustup run 1.83 cargo build --release
  3. still have "error[E0658]: exclusive range pattern syntax is experimental" error
diff --git a/autoload/clap/installer.vim b/autoload/clap/installer.vim
index 446ff68..e5133c6 100644
--- a/autoload/clap/installer.vim
+++ b/autoload/clap/installer.vim
@@ -33,6 +33,8 @@ function! s:run_term(cmd, cwd, success_info, ErrorCallback) abort
     let cmd = a:cmd
     if has('win32')
       let cmd = 'cmd.exe /c '.cmd
+    else
+      let cmd = &shell.' -c "'.cmd.'"'
     endif
     call term_start(cmd, {
           \ 'curwin': 1,
@@ -117,9 +119,9 @@ function! clap#installer#build_maple() abort
     endif
 
     if empty(filter(split(system('rustup toolchain list')), 'v:val =~ l:rust_version'))
-      let cmd = printf('rustup install %s && cargo +%s build --release', rust_version)
+      let cmd = printf('rustup install %s && rustup run %s cargo build --release', rust_version, rust_version)
     else
-      let cmd = printf('cargo +%s build --release', rust_version)
+      let cmd = printf('rustup run %s cargo build --release', rust_version)
     endif
 
     call s:run_term(cmd, s:plugin_root_dir, 'built maple binary successfully', {-> clap#helper#echo_warn('build maple failed')})

@liuchengxu
Copy link
Owner

liuchengxu commented Jan 28, 2025

As I have said, try to run cargo build --release from the repo's root directly from the terminal rather than within Vim. Everything will be fine if you compile the binary in 1.83 as specified by rust-toolchain.toml.

@liuchengxu liuchengxu reopened this Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants