LeEnno/alfred-terminalfinder

Error on using "fi"

Closed this issue · 18 comments

This error occurs when using "fi" command

[ERROR: alfred.workflow.action.applescript] {
    NSAppleScriptErrorBriefMessage = "Expected class name but found identifier.";
    NSAppleScriptErrorMessage = "Expected class name but found identifier.";
    NSAppleScriptErrorNumber = "-2741";
    NSAppleScriptErrorRange = "NSRange: {417, 8}";
}

Hey there, a few questions:

  1. Which OS version are you on?
  2. What's the file's path?
  3. Which Finder view do you use? (symbol, list, column)

Thanks for reporting!

Hey @LeEnno sorry for not reporting all the info.

OS X 10.9.4
I'm using list view in Finder
iTerm Build 2.9.20140916-nightly (stable not working also)
Alfred 2.4 (279)

Standard Terminal app is working properly.

BTW, awesome workflow!

Thanks for the info. Could you please also give the path for the directory you're trying to open in iTerm? This enables me to reproduce the issue and hopefully fix it.

Any directory I tried has this error.

That's weird. Let's try to track down where the issue occurs. Please paste the contents of the following AppleScript into a new file (open AppleScript Editor from your Applications folder):

tell application "Finder"
    set pathList to (quoted form of POSIX path of (folder of the front window as alias))
end tell

tell application "System Events"
    set isRunning to (exists (processes where name is "iTerm"))
end tell

tell application "iTerm"
    set termCount to count of terminals

    if termCount is 0 then
        set myTerm to (make new terminal)
    else
        set myTerm to the first terminal
    end if

    tell myTerm
        if not isRunning and termCount is not 0 then
            set mySession to current session
        else
            set mySession to (launch session "Default")
        end if
        tell mySession to write text "cd " & pathList

    end tell

    activate
end tell

Click the execute button at the top. Hopefully you'll get a more detailed error message (⌘3 should bring up events and responses) and even a highlighted error position.

Bonus: try it a second time with iTerm already opened (or close it if you had it running the first time, you know).

We'll get that nasty thing ;)

This is what a get:
screen shot 2014-09-17 at 18 42 23

Ok, thanks.

  1. Which version of iTerm do you use?
  2. What's the output of the following AppleScript?
tell application "iTerm"
    return terminals
end tell

error "The variable terminals is not defined." number -2753 from "terminals"

I'm getting this with iTerm Build 2.9.20141005-nightly and Yosemite, fwiw.

Thanks for your response, @MarioRicalde. That's weird. I will setup a Yosemite VM, have a look at this and report back. Just be a little patient, please. Busy times right now.

I use Yosemite with iTerm 2.0.0.20141022 and it works just fine. Unfortunately I have no idea what could cause the issue :(

Sorry for not getting back to you - it seems that there's an issue with the latest versions of iTerm, specifically the ones that are on the beta and on the nightly build.

By looking at the commit logs in the iTerm repository, I gather that they're changing their implementation when it comes down to iTerm.

Well, that sucks. Maybe someone should hint them at AppleScript not working properly in their latest builds. wink wink ;)

I’m using iTerm 2.0 and for me it is not working. I tried your above script, and also added

display dialog pathList

And this displays correctly. However, the "cd" text is not sent to the iTerm.

A few questions:

  1. Which version of OS X and iTerm do you use?
  2. What happens instead? Does iTerm open? Does it come to the front? Does the script display any errors?

@LeEnno

  1. OSX 10.10.2 - iTerm 2.0 (from About)
  2. iTerm opens and comes to the front, the script does not throw any error. It is just that the "cd" & pathList => command is not executed on iTerm.

That's weird. What happens when executing the following script?

tell application "iTerm"
    tell (make new terminal)
        set pathList to "~/Documents"
        tell (launch session "Default") to write text "cd " & pathList
    end tell
end tell

Hello, this works now.. also your Alfred extension works.. Not sure what the problem was though..

Well, I love problems which solve themselves.
I will close this issue for now. Feel free to reopen if necessary.