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

Error fetching crate #153

Closed
flaport opened this issue Feb 18, 2025 · 12 comments
Closed

Error fetching crate #153

flaport opened this issue Feb 18, 2025 · 12 comments
Labels
bug Something isn't working

Comments

@flaport
Copy link

flaport commented Feb 18, 2025

Important

This issue has been fixed, update to the latest stable version

Description

Hi, not sure what's going on, but today when I wanted to bump some of my dependencies I got this:

Image

Not so long ago (last week?) I did not have any issues...

Neovim version

NVIM v0.11.0-dev-4a2a54f

Health check

Checking plugins ~ - null-ls.nvim not found - neoconf.nvim not found - OK nvim-cmp installed - coq_nvim not found Checking external dependencies ~ - OK curl installed

Operating system and version

Arch Linux

Expected behavior

I expect at least some versions to resolve.

Actual behavior

maybe the api is down? Then again, I manually checked https://crates.io/api/v1/crates/bevy for example and that seemed to work

Minimal config

local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
  local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
  vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
end
vim.opt.rtp:prepend(lazypath)

require('lazy').setup {
{
    'saecki/crates.nvim',
    tag = 'stable',
    config = function()
        require('crates').setup()
    end,
}
}

Cargo.toml

[package]
name = "my_package"
version = "0.0.0"
edition = "2021"

[features]
default = ["fast-compile"]
fast-compile = ["bevy/dynamic_linking"]
dark-mode = []

[dependencies]
anyhow = "1.0.93"
bevy = { version = "0.14.2" }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
reqwest = {version="0.12.9", features=["blocking"]}

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen-futures = "0.4.45"
js-sys = "0.3.72"

[profile.dev]
opt-level = 1
overflow-checks = false

[profile.release]
opt-level = 3
lto = "thin"
codegen-units = 1

[profile.wasm-release]
inherits = "release"
opt-level = "s"
strip = "debuginfo"

Steps to reproduce

  1. nvim --clean -u minimal.lua
@flaport flaport added the bug Something isn't working label Feb 18, 2025
@39george
Copy link

I am observing the same behavior on Arch Linux. Could the recent curl update be the reason?

@saecki
Copy link
Owner

saecki commented Feb 18, 2025

What curl version are you using?

@flaport
Copy link
Author

flaport commented Feb 18, 2025

$ curl --version
curl 8.12.1 (x86_64-pc-linux-gnu) libcurl/8.12.1 OpenSSL/3.4.1 zlib/1.3.1 brotli/1.1.0 zstd/1.5.6 libidn2/2.3.7 libpsl/0.21.5 libssh2/1.11.1 nghttp2/1.64.0 nghttp3/1.7.0
Release-Date: 2025-02-13
Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp ws wss
Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTP3 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM PSL SPNEGO SSL threadsafe TLS-SRP UnixSockets zstd

@Leandros
Copy link
Contributor

Leandros commented Feb 18, 2025

Same error started appearing here. This morning everything was working, since lunch break (about 2 hours ago), it stopped working.

%% curl --version
curl 8.3.0 (x86_64-koji-linux-gnu) libcurl/8.3.0 OpenSSL/1.0.2k-fips zlib/1.2.7 libidn2/2.3.0 libpsl/0.21.5 (+libidn2/2.3.0) libssh2/1.4.3 nghttp2/1.41.0 OpenLDAP/2.4.44
Release-Date: 2023-09-13
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp ws wss
Features: alt-svc AsynchDNS GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL threadsafe UnixSockets
# /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
HOME_URL="https://amazonlinux.com/"
%% nvim --version
NVIM v0.10.3
Build type: Release
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info

Can I somehow enable logging, to better diagnose this?

@Dr-42
Copy link

Dr-42 commented Feb 18, 2025

I am getting the same errors on arch linux

@Leandros
Copy link
Contributor

Leandros commented Feb 18, 2025

@saecki: It's failing to parse the created_at and updated_at dates from the JSON response as RCF3339 date here:

created = assert(DateTime.parse_rfc_3339(c.created_at)),
updated = assert(DateTime.parse_rfc_3339(c.updated_at)),

and further down here as well:

version.created = assert(DateTime.parse_rfc_3339(v.created_at))

They must've changed the format, somehow.

This is the format I receive from, for example, clap:

{
  badges = {},
  categories = { "command-line-interface" },
  created_at = "2015-03-01T01:17:24.903018Z",
  default_version = "4.5.30",
  description = "A simple to use, efficient, and full-featured Command Line Argument Parser",
  downloads = 356318746,
  exact_match = false,
  id = "clap",
  keywords = { "parser", "argument", "cli", "parse", "arg" },
  links = {
    owner_team = "/api/v1/crates/clap/owner_team",
    owner_user = "/api/v1/crates/clap/owner_user",
    owners = "/api/v1/crates/clap/owners",
    reverse_dependencies = "/api/v1/crates/clap/reverse_dependencies",
    version_downloads = "/api/v1/crates/clap/downloads"
  },
  max_stable_version = "4.5.30",
  max_version = "4.5.30",
  name = "clap",
  newest_version = "4.5.30",
  num_versions = 423,
  recent_downloads = 44077457,
  repository = "https://github.com/clap-rs/clap",
  updated_at = "2025-02-17T19:01:15.547614Z",
  versions = { 1450078, 1442767, 1432124, 1415370, 1401451, 1401213, 1398655, 1365181, 1362200, 1338785, 1294788, 1287242, 1276460, 1259660, 1237214, 1229889, 1227911, 12202
17, 1220021, 1214398, 1212478, 1197201, 1188246, 1169775, 1167000, 1166901, 1093885, 1083782, 1074695, 1054067, 1044643, 1016067, 1014684, 1011805, 1011112, 1007665, 1004124
, 998254, 975690, 969884, 969148, 951491, 934045, 909954, 906877, 900428, 895760, 886351, 883483, 880519, 878760, 875360, 874283, 866561, 866556, 851862, 851769, 849847, 849
171, 848464, 848130, 848111, 846174, 839573, 835005, 833433, 830312, 830303, 830180, 827242, 822570, 819104, 816263, 814161, 803682, 790757, 790731, 787227, 787205, 785001,
780498, 779735, 775709, 762770, 761827, 761209, 757765, 757504, 753398, 752771, 751543, 737854, 737212, 727809, 727733, 710608, 709933, 709668, 703183, 702547, 689994, 68998
4, 688817, 672881, 672593, 670090, 664919, 664335, 663684, 661676, 658953, 658936, 658838, 657004, 648962, 646525, 644593, 644243, 641353, 640333, 639476, 638878, 638028, 63
5160, 633908, 632541, 632092, 631957, 631924, 631403, 631366, 630809, 630725, 630661, 629223, 626184, 625322, 622750, 619588, 613246, 611556, 610901, 601137, 593237, 590929,
 587692, 586968, 584414, 583843, 582921, 576020, 574617, 570473, 567219, 566746, 566616, 566484, 565995, 565982, 546921, 544895, 544551, 542663, 541910, 541623, 536367, 5362
24, 534853, 533249, 525577, 525071, 511683, 509185, 509167, 507958, 505094, 503723, 500956, 493561, 490550, 489004, 488867, 485210, 484734, 484483, 481952, 481031, 477996, 4
77312, 477267, 477191, 476652, 475431, 475411, 475394, 475056, 475041, 473592, 472218, 469382, 469309, 468489, 466265, 465937, 465934, 465610, 465185, 460469, 460468, 439059
, 413183, 413177, 285288, 272574, 269756, 240165, 237313, 143448, 97981, 85511, 83571, 83483, 80995, 79983, 79883, 77695, 76915, 73625, 72568, 69418, 69278, 65538, 65325, 61
045, 60282, 57251, 53450, 52578, 52318, 50695, 49949, 49551, 49541, 49124, 48650, 48514, 48511, 48233, 47624, 47612, 45744, 45741, 45550, 44419, 44384, 43806, 41698, 41014,
39286, 38929, 38237, 37341, 37100, 37078, 36956, 36874, 36683, 36625, 36612, 36439, 36417, 35201, 34269, 33915, 33911, 33275, 33193, 33184, 32613, 32459, 32408, 32223, 32147
, 30911, 30655, 29537, 29441, 29437, 29356, 29321, 29266, 28660, 27966, 26906, 26871, 26833, 26830, 26828, 26556, 25784, 25779, 24975, 24719, 24650, 24561, 24059, 23958, 228
67, 22633, 22352, 22131, 21894, 21863, 21794, 21685, 21497, 21477, 20197, 19538, 18324, 18105, 18088, 18080, 17549, 17370, 16468, 16461, 16259, 16021, 15999, 15531, 15489, 1
5407, 15322, 15079, 15065, 14959, 14911, 14797, 14602, 13956, 13848, 13418, 13347, 13283, 13282, 13237, 13005, 12913, 12861, 12817, 12492, 11844, 11410, 11409, 11070, 11046,
 10759, 10602, 10512, 10395, 10390, 10376, 10313, 10216, 10145, 9985, 9921, 9910, 9870, 9822, 9815, 9812, 9790, 9660, 9655, 9575, 9510, 9196, 9063, 9026, 8951, 8918, 8835, 8
800, 8795, 8658, 8643, 8197, 8094, 7962, 7948, 7870, 7596, 7593, 7581, 7539, 7516, 7502, 7496, 7427, 7407, 7303, 7254, 6947, 6930, 6871, 6869, 6868, 6665, 6552, 6537, 6519,
6502, 6501, 6463, 6441, 6431, 6409, 6406, 5925, 5911, 5796 },
  yanked = false
}

The regex fails to recognize the Z as the correct timezone, it expects +HH:MM instead.

@flaport
Copy link
Author

flaport commented Feb 18, 2025

Now that @Leandros found where the issue occurs, I was able to 'fix' it as follows:

I edited ~/.local/share/nvim/lazy/crates.nvim/lua/crates/time.lua and changed the regex as follows:

    -- local pat = "^([0-9][0-9][0-9][0-9])%-([0-9][0-9])%-([0-9][0-9])" -- date
    --     .. "T([0-9][0-9]):([0-9][0-9]):([0-9][0-9])%.[0-9]+" -- time
    --     .. "([%+%-])([0-9][0-9]):([0-9][0-9])$" -- offset
    -- local year, month, day, hour, minute, second, offset, offset_hour, offset_minute = str:match(pat)

    local pat = "^([0-9][0-9][0-9][0-9])%-([0-9][0-9])%-([0-9][0-9])" -- date
        .. "T([0-9][0-9]):([0-9][0-9]):([0-9][0-9])%.[0-9]+Z$" -- time

    local year, month, day, hour, minute, second = str:match(pat)
    local offset = 0
    local offset_hour = 0
    local offset_minute = 0

This seems to fix it for me.

@Leandros
Copy link
Contributor

Leandros commented Feb 18, 2025

Quick and dirty patch for everyone that fixes the issue:

diff --git a/lua/crates/time.lua b/lua/crates/time.lua
index 40c7919..c69b4c0 100644
--- a/lua/crates/time.lua
+++ b/lua/crates/time.lua
@@ -17,7 +17,7 @@ function DateTime.parse_rfc_3339(str)
     -- lua regex suports no {n} occurences
     local pat = "^([0-9][0-9][0-9][0-9])%-([0-9][0-9])%-([0-9][0-9])" -- date
         .. "T([0-9][0-9]):([0-9][0-9]):([0-9][0-9])%.[0-9]+"          -- time
-        .. "([%+%-])([0-9][0-9]):([0-9][0-9])$"                       -- offset
+        .. "([%+%-Z])([0-9]?[0-9]?):?([0-9]?[0-9]?)$"                       -- offset

     local year, month, day, hour, minute, second, offset, offset_hour, offset_minute = str:match(pat)
     if year then
@@ -29,6 +29,9 @@ function DateTime.parse_rfc_3339(str)
         elseif offset == "-" then
             h = tonumber(hour) - tonumber(offset_hour)
             m = tonumber(minute) - tonumber(offset_minute)
+        elseif offset == 'Z' then
+            h = tonumber(hour)
+            m = tonumber(minute)
         end
         return DateTime.new(os.time({
             ---@diagnostic disable-next-line: assign-type-mismatch

This makes sure that the dates are still available properly.

@Leandros
Copy link
Contributor

PR with fix: #154

@saecki
Copy link
Owner

saecki commented Feb 18, 2025

I've merged the PR for parsing an explicit UTC offset, does that fix the issue here?

@helio-frota
Copy link

getting the same on fedora 41 👍

@saecki saecki closed this as completed Feb 18, 2025
@helio-frota
Copy link

fixed for me @saecki 👍

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

6 participants