Clojure NPE主要(Clojure NPE in main)
我在我的clojure hello世界里得到了这个奇怪的NPE
(ns test-app.core (:gen-class)) (defn -main [& args] ( (println "Hello")) )
注意(println“Hello”)周围的extra()。 这似乎是问题,如果我删除它就好了。
和程序的输出。 请注意,代码实际上打印了“Hello”并且扔了。
Hello Exception in thread "main" java.lang.NullPointerException at test_app.core$_main.doInvoke(core.clj:5) at clojure.lang.RestFn.invoke(RestFn.java:397) at clojure.lang.Var.invoke(Var.java:411) at user$eval5$fn__7.invoke(form-init9064825970813284041.clj:1) at user$eval5.invoke(form-init9064825970813284041.clj:1) at clojure.lang.Compiler.eval(Compiler.java:6619) at clojure.lang.Compiler.eval(Compiler.java:6609) at clojure.lang.Compiler.load(Compiler.java:7064) at clojure.lang.Compiler.loadFile(Compiler.java:7020) at clojure.main$load_script.invoke(main.clj:294) at clojure.main$init_opt.invoke(main.clj:299) at clojure.main$initialize.invoke(main.clj:327) at clojure.main$null_opt.invoke(main.clj:362) at clojure.main$main.doInvoke(main.clj:440) at clojure.lang.RestFn.invoke(RestFn.java:421) at clojure.lang.Var.invoke(Var.java:419) at clojure.lang.AFn.applyToHelper(AFn.java:163) at clojure.lang.Var.applyTo(Var.java:532) at clojure.main.main(main.java:37) [Finished in 4.0s with exit code 1]
我的问题是为什么会发生这种情况?
或者更好:这是一个错误或预期的行为?
我假设这是因为列表的第一个arg应该是一个函数的名称,这里是另一个列表:P。 但在这种情况下,编译器/运行时不应该给出更好的错误吗?
Thx提前。
I'm getting this weird NPE in my clojure hello world
(ns test-app.core (:gen-class)) (defn -main [& args] ( (println "Hello")) )
Notice the extra () around the (println "Hello"). That seems to be the problem, if i remove that its just fine.
And the output of the program. Notice that the code actually printed "Hello" and the threw.
Hello Exception in thread "main" java.lang.NullPointerException at test_app.core$_main.doInvoke(core.clj:5) at clojure.lang.RestFn.invoke(RestFn.java:397) at clojure.lang.Var.invoke(Var.java:411) at user$eval5$fn__7.invoke(form-init9064825970813284041.clj:1) at user$eval5.invoke(form-init9064825970813284041.clj:1) at clojure.lang.Compiler.eval(Compiler.java:6619) at clojure.lang.Compiler.eval(Compiler.java:6609) at clojure.lang.Compiler.load(Compiler.java:7064) at clojure.lang.Compiler.loadFile(Compiler.java:7020) at clojure.main$load_script.invoke(main.clj:294) at clojure.main$init_opt.invoke(main.clj:299) at clojure.main$initialize.invoke(main.clj:327) at clojure.main$null_opt.invoke(main.clj:362) at clojure.main$main.doInvoke(main.clj:440) at clojure.lang.RestFn.invoke(RestFn.java:421) at clojure.lang.Var.invoke(Var.java:419) at clojure.lang.AFn.applyToHelper(AFn.java:163) at clojure.lang.Var.applyTo(Var.java:532) at clojure.main.main(main.java:37) [Finished in 4.0s with exit code 1]
My question is why is this happening?
Or better: So is this a bug in or is it expected behaviour?
I assume that's because the first arg of a list should be the name of a function, and here its another list :P. but shouldn't the complier/runtime give a nicer error in that case?
Thx in advance.
原文:https://stackoverflow.com/questions/24172983
相关问答
更多-
我正在使用Rails 3.0.3,这是Rails 3和bundler的新功能。 我得到了这个相同的错误: gem 'mygem', :path => '/path/to/gem' 通过指定版本号来解决: gem 'mygem', '0.0.1', :path => '/path/to/gem' 版本使用>=0.0.1恢复为原始错误。 然而,我无法解释这一点。 从Gemfile手册页引用JD的有用的提示:“类似于:git选项的语义,:path选项要求所讨论的目录包含gem的.gemspec,或者指定一个明 ...
-
我不认为这是一个Rails版本问题,也不是Heroku特有的问题。 (我今天遇到同样的问题,在我的本地开发机器上运行bundle install时,使用Rails 3.0.3。) 如Andrew所说,在本地运行bundle update解决问题。 编辑 :正如在评论中建议:记得要git add . , git commit -m "message" I don't think it's a Rails version problem, nor is it specific to Heroku. (I hit ...
-
这是由于Bundler最近引入的变化。 我们(Heroku)需要追踪它为什么认为它运行在--dry-run模式并修复它。 与此同时,这不是有害的,不应该引起任何问题。 不幸的是,如果您担心这一点,则无法手动清除缓存。 This is due to a recently-introduced change in Bundler. We (Heroku) need to track down why it thinks it is running in --dry-run mode and fix it. In ...
-
它很短,但没有。 如果您正在使用Bundler,那么您要规定Gemfile中使用了哪些版本(这些版本又定义了Gemfile.lock中的版本号,两者都应该提交给Git)。 如果您没有使用Bundler,并且仍然在项目的根目录中使用.gems文件,Heroku将使用它最新的文件,除非您定义了不同的版本,在这种情况下它将使用它。 更多信息可以在这里找到: http : //devcenter.heroku.com/articles/gems It short, it doesn't. If you're usi ...
-
(假设您没有依赖项问题)您可以运行软件包更新,或者在Gemfile中,您可以删除版本号或获取所需的特定版本,然后执行软件包更新。 如果你确实需要那些版本,那么我猜你需要在bundle exec加上命令,然后让bundler管理依赖项。 例如bundle exec rspec spec/.. (Assuming that you don't have an dependency issues) You can run a bundle update or In your Gemfile, you can re ...
-
您跳过了部分安装说明 ,即: 我们需要将Gemfile.lock切换到PostgreSQL。 编辑Gemfile并将ENV['DB'] ||= 'mysql'更改为ENV['DB'] ||= 'postgres' 。 然后运行: bundle --without development test heroku production assets git add Gemfile Gemfile.lock git commit -m "switch Gemfile.lock to pg exclusivly" ...
-
Heroku:由于gem install bundler,无法推送到Heroku(Heroku: Cannot push to Heroku due to gem install bundler)[2020-01-28]
我联系了Heroku,他们告诉我我有多个buildpack: 感谢您就安装红宝石的问题与我们联系。 似乎该应用程序已将Heroku Buildpack for Ruby指定两次,后者指定主版本而不是发布版本: $ heroku buildpacks -a app-name === app-name Buildpack URLs 1. heroku/ruby 2. https://github.com/heroku/heroku-buildpack-nodejs.git 3. https://github.c ... -
确保heroku不是你的Gemfile一部分 - 它不应该在那里。 然后删除./bundler_stubs/heroku : rm -f ./bundler_stubs/heroku ./bundler_stubs/heroku可能是您项目的一部分,并且是由您的同事提交的,存根不应该是项目的一部分。 make sure heroku is not part of your Gemfile - it should not be there. then remove ./bundler_stubs/herok ...
-
Bundler确保Ruby可以找到Gemfile中的所有gem(及其所有依赖项)。 它通过配置加载路径来实现,因此可能需要Gemfile中的所有依赖项。 这是通过以下调用完成的: Bundler.setup ruby LOAD_PATH是文件系统上ruby将查找文件的位置列表,如果你需要的话。 我认为它类似于Linux / Windows操作系统中的PATH变量,但是对于ruby。 要查看此操作,请以root用户身份运行load_path。 我是从我的mac做的 $ sudo ruby -e 'p $LO ...
-
我解决了这个问题,如下所示! 谢谢你的帮助! gem 'net-ssh', '!= 2.10.0' bundle update I've solved the problem doing as follows! Thank your for your help! gem 'net-ssh', '!= 2.10.0' bundle update