我在使用"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}我在package require http后面添加了:
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 ..."发布于 2017-07-01 07:45:19
看起来您/NaviServer正在以某种方式在解释器中重新加载http包,该解释器已经加载了不同版本的http包。这很奇怪。
更奇怪的是,以这种方式工作的http库的最新版本可以追溯到2004年;它在http 2.5.0中进行了更改,该版本是在2005年初升级到该版本的。(显然是我做的,但我真的不记得了。)这一变化适用于TCL8.4和8.5版本(以及8.6和更高版本),所以我非常确定您正在使用的旧版本真的不值得使用。这是版本的上限,这些版本足够老,可以触发你现在看到的行为;它们可能比这个更老。
总而言之,这绝对是奇怪的。你不应该把一个包的不同版本加载到一个Tcl解释器中。这不是一个特别受支持的使用模式(主要是因为大多数包不能很好地卸载它们的状态,因为很难做到很好)。
一种解决方法是在package require之前执行此操作
catch {namespace delete ::http}https://stackoverflow.com/questions/44851900
复制相似问题