我在使用“package require http”时遇到问题。如果我只有一个包含该行的tcl文件,我会收到以下错误:
can't set "formMap": variable is array
while executing
"variable formMap [array get map]"
(procedure "init" line 15)
invoked from within
"init"
(in namespace eval "::http" script line 42)
invoked from within
"namespace eval http {
# Allow resourcing to not clobber existing data
variable http
if {![info exists http]} {
array set http {
-ac..."
(file "/usr/local/naviserver4910/lib/tcl8/8.4/http-2.7.13.tm" line 16)
invoked from within
"source -encoding utf-8 /usr/local/naviserver4910/lib/tcl8/8.4/http-2.7.13.tm"
("package ifneeded http 2.7.13" script)
invoked from within
"package require http"
("uplevel" body line 2)
invoked from within
"uplevel {
package require http
有人可以帮我解决这个问题吗?谢谢。
编辑 - >包括:
之后catch {namespace delete ::http}
我跟着包需要http with:
http::geturl "https://google.com"
但是,我现在收到以下错误:
invalid command name "http::geturl"
while executing
"http::geturl "https://google.com""
("uplevel" body line 4)
invoked from within
"uplevel {
catch {namespace delete ::http}
package require http
http::geturl "https://google.com"
set user_id [ad_conn user_id]
set events_o..."
(procedure "code::tcl::/web/dev/nnab-codebook/packages/ctrl-ars/www/inde..." line 2)
invoked from within
"uplevel {
if { [file exists $__adp_stub.tcl] } {
# ensure that data source preparation procedure exists and is up-to-date
..."
(procedure "adp_prepare" line 2)
invoked from within
"adp_prepare"
invoked from within
"template::adp_parse [file rootname [ad_conn file]] {}"
(procedure "adp_parse_ad_conn_file" line 6)
invoked from within
"$handler"
("uplevel" body line 2)
invoked from within
"uplevel $code"
invoked from within
"ad_try {
$handler
} ad_script_abort val {
# do nothing
}"
invoked from within
"rp_serve_concrete_file [ad_conn file]"
(procedure "::nsf::procs::rp_serve_abstract_file" line 60)
invoked from within
"rp_serve_abstract_file "$root/$extra_url""
("uplevel" body line 2)
invoked from within
"uplevel $code"
invoked from within
"ad_try {
rp_serve_abstract_file "$root/$extra_url"
set tcl_url2file([ad_conn url]) [ad_conn file]
set ..."
答案 0 :(得分:1)
看起来你/ NaviServer以某种方式在已经加载了不同版本的解释器中重新加载http包。这很奇怪。
那个以这种方式工作的最年轻的http库版本可以追溯到2004年,这是多么奇怪的事情。它在http 2.5.0中被改变了,它在2005年初被推进到那个版本。(显然我做到了,但我真的不记得了。)这个改变适用于Tcl 8.4和8.5版本(还有8.6和更高版本)所以我很确定你使用的古老版本真的不值得使用。那个 upper 绑定的版本已足够大,可以触发您所看到的行为;他们可能比这更老了。
总而言之,这绝对是奇怪的。您实际上并不应该将不同版本的软件包加载到单个Tcl解释器中。这不是一个特别受支持的使用模式(主要是因为大多数软件包都不能很好地卸载它们的状态,因为很难做好)。
解决方法是在 package require
:
catch {namespace delete ::http}