Running Oracle Instant Client and related SQL*Plus on Mac OS X, with tnsnames.ora created and environment variables setup correctly was causing this error repeatedly, not allowing login into the database via “sqlplus” from a terminal/command line.
ORA-12169: TNS:Net service name given as connect identifier is too long
The tnsnames.ora file was good, and there was nothing unusual about the “service_name” used in the TNS entries. So this error was a bit surprising.
The reason was simple, the tnsnames.ora file had Windows encoding (CR/LF) instead of Unix/Linux encoding (just LF). Just saving the tnsnames.ora file in *nix format solved the problem !
Hope that this information is useful to others.