zino-rs / zino

Next-generation framework for composable applications in Rust.
https://crates.io/crates/zino
MIT License
762 stars 52 forks source link

could not get local offset: IndeterminateOffset #98

Closed ll9160 closed 5 months ago

ll9160 commented 5 months ago

编译环境:macosx rust版本: 1.77.2 报错位置:zino-core-0.21.3/src/application/tracing_subscriber.rs:33:58 描述:我单纯的运行 examples/actix-app 直接报如下错误:could not get local offset: IndeterminateOffset;因为是zino-core 里面的一个逻辑触发了,我又运行了其他几个例子报一样的错误。 这个错误似乎是 time 包的某个版本导致的,time-issue 希望得到帮助

photino commented 5 months ago

一个类似的问题之前在Ubuntu上遇到过:https://github.com/tokio-rs/tracing/issues/2450 后来修正了。在Windows下没问题,不知道在MacOS上为啥会有问题

你可以试试这个命令能不能编译通过

USTFLAGS="--cfg unsound_local_offset" cargo build
ll9160 commented 5 months ago

一个类似的问题之前在Ubuntu上遇到过:tokio-rs/tracing#2450 后来修正了。在Windows下没问题,不知道在MacOS上为啥会有问题

你可以试试这个命令能不能编译通过

USTFLAGS="--cfg unsound_local_offset" cargo build

编译没问题,运行还是报我描述的错误

photino commented 5 months ago

这个错误 估计是tracing-subscriber启用了local-time的问题 你可以单独使用这个库 试试能运行个demo吗 如果也不能,那就确定是tracing-subscriber的问题了

ll9160 commented 5 months ago

我看了是zino-core默认依赖的 local-time 这个特性,直接关闭不行,在 https://github.com/zino-rs/zino/blob/main/zino-core/src/application/tracing_subscriber.rs#L33 上依赖的,我单独使用tracing-subscriber 关闭这个特性是可以的

photino commented 5 months ago

也就是说 你单独使用tracing-subscriber 如果启用了 local-time 它也是会报错了

photino commented 5 months ago

主要是这个LocalTime为啥会报错呢 如果获取不到系统的 local offset 那本地时区的DateTime还怎么用呢

ll9160 commented 5 months ago

嗯,找到问题了,是因为目标架构不匹配的问题,电脑是M1的芯片,通过rust官网的安装方式默认是x86_64的,因为local offset是用系统的时间库,因为架构的不一样,获取上失败了,报错,我卸载后,重新指定安装aarch64-apple-darwin 就可以了

ll9160 commented 5 months ago

👍 感谢提供的帮助和支持,针对M1芯片,如果出现如上报错,可以通过以下步骤尝试解决:

rustup self uninstall
arch --x86_64 \                                                                                                     
sh <(curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs) \
--default-host aarch64-apple-darwin