Opened 2 years ago

Last modified 15 months ago

#59381 new enhancement

Do something better when no ports are specified

Reported by: 6aKa Owned by:
Priority: Normal Milestone:
Component: base Version:
Keywords: Cc:
Port:

Description

zeus local # pwd
/opt/local
zeus local # id
uid=0(root) gid=0(wheel) groups=0(wheel),1(daemon),2(kmem),3(sys),4(tty),5(operator),8(procview),9(procmod),12(everyone),20(staff),29(certusers),61(localaccounts),80(admin),701(com.apple.sharepoint.group.1),33(_appstore),98(_lpadmin),100(_lpoperator),204(_developer),250(_analyticsusers),395(com.apple.access_ftp),398(com.apple.access_screensharing),399(com.apple.access_ssh),400(com.apple.access_remote_ae)
zeus local # port -d version
DEBUG: Copying /Users/baka/Library/Preferences/com.apple.dt.Xcode.plist to /opt/local/var/macports/home/Library/Preferences
Version: 2.6.1
zeus local # port -d clean
DEBUG: Copying /Users/baka/Library/Preferences/com.apple.dt.Xcode.plist to /opt/local/var/macports/home/Library/Preferences
DEBUG: Using normalized porturl file:///opt/local
DEBUG: Changing to port directory: /opt/local
DEBUG: Could not find Portfile in /opt/local
    while executing
"mportopen $url"
Can't map the URL 'file://.' to a port description file ("Could not find Portfile in /opt/local").
Please verify that the directory and portfile syntax are correct.
To use the current port, you must be in a port's directory.
zeus local # xcodebuild -version
Xcode 11.1
Build version 11A1027

Change History (6)

comment:1 Changed 2 years ago by 6aKa

may be when port clean execute without portname, need clean all in /opt/local/var/macports/{build,logs} or print good help

comment:2 Changed 2 years ago by 6aKa

or add failed set for port echo failed and port clean failed

comment:3 Changed 2 years ago by jmroot (Joshua Root)

Component: portsbase
Summary: port clean not workingport clean: do something better when no ports are specified
Type: defectenhancement

comment:4 Changed 2 years ago by 6aKa

the same situation with port install, port uninstall, port info and other actions.

comment:5 in reply to:  2 Changed 15 months ago by ryandesign (Ryan Schmidt)

Summary: port clean: do something better when no ports are specifiedDo something better when no ports are specified

Replying to 6aKa:

zeus local # port -d clean
DEBUG: Copying /Users/baka/Library/Preferences/com.apple.dt.Xcode.plist to /opt/local/var/macports/home/Library/Preferences
DEBUG: Using normalized porturl file:///opt/local
DEBUG: Changing to port directory: /opt/local
DEBUG: Could not find Portfile in /opt/local
    while executing
"mportopen $url"
Can't map the URL 'file://.' to a port description file ("Could not find Portfile in /opt/local").
Please verify that the directory and portfile syntax are correct.
To use the current port, you must be in a port's directory.

It's behaving as designed. When you don't specify a port name, it uses the portfile in the current directory. You were in a directory that didn't have a portfile in it, hence the error. I agree we could improve the error message to make it clearer to new users who are not familiar with this feature and may not have intended to invoke this feature.

Replying to 6aKa:

may be when port clean execute without portname, need clean all in /opt/local/var/macports/{build,logs} or print good help

MacPorts developers use this feature—invoking MacPorts commands without specifying the port name—all the time while developing their ports, so changing it would break their existing workflows.

Replying to 6aKa:

or add failed set for port echo failed and port clean failed

All of the existing pseudoports can be computed from the portindex or registry. "failed" cannot so we would need to invent new capabilities for the pseudoport feature to be able to scan the disk and find the failed build directories. Even so, finding a build directory does not necessarily indicate that a build failed. The user could have stopped the build intentionally, or could have invoked a MacPorts command that leaves behind a build directory, such as sudo port extract. So maybe "dirty" is a better name for such a pseudoport than "failed".

comment:6 Changed 15 months ago by ryandesign (Ryan Schmidt)

There's also some difficulty with tracing a particular build directory back to the port that created it. The user may have multiple ports trees; a build directory could be from any of them. Suppose a user has a build directory from the port zlib from the main ports tree, and then makes a local port repository and copies the zlib port there, modifies it, and builds it. Now the user has a second build directory for that copy of zlib. So even though we could write new code to scan the build directory and translate those build directory names back to port names, in this case we would find that there are two build directories for zlib, but telling MacPorts to clean zlib would only clean one of them (whichever one came first in sources.conf).

So that may doom the "failed" or "dirty" pseudoport idea. A better way to accomplish the task of cleaning up failed builds is through reclaim; see #60126. This improvement to reclaim will be in a future version of MacPorts.

Note: See TracTickets for help on using tickets.